I am working on rails project where i have used mongodb as backend , i am using mongo_mapper as ORM , i have followed the instructions from the below site
: http://www.mongodb.org/display/DOCS/Rails+3+-+Getting+Started .
But while running the server (i.e rails s or rails c) i am getting the following error.
/home/vijay/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:196:in `merge!': can't convert String into Hash (TypeError)
from /home/vijay/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:196:in `block in visit_Psych_Nodes_Mapping'
from /home/vijay/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:190:in `each'
from /home/vijay/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:190:in `each_slice'
from /home/vijay/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:190:in `visit_Psych_Nodes_Mapping'
from /home/vijay/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/visitor.rb:7:in `accept'
from /home/vijay/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:16:in `accept'
from /home/vijay/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/nodes/node.rb:25:in `to_ruby'
from /home/vijay/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:107:in `load'
from /home/vijay/.rvm/gems/ruby-1.9.2-p290/gems/mongo_mapper-0.11.0/lib/mongo_mapper/railtie.rb:27:in `block in <class:Railtie>'
from /home/vijay/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/initializable.rb:30:in `instance_exec'
from /home/vijay/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/initializable.rb:30:in `run'
from /home/vijay/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/initializable.rb:55:in `block in run_initializers'
from /home/vijay/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/initializable.rb:54:in `each'
from /home/vijay/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/initializable.rb:54:in `run_initializers'
from /home/vijay/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/application.rb:96:in `initialize!'
from /home/vijay/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /home/vijay/Desktop/rails_project/newfolder/Mongo_St/config/environment.rb:5:in `<top (required)>'
from /home/vijay/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/application.rb:83:in `require'
from /home/vijay/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/application.rb:83:in `require_environment!'
from /home/vijay/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/commands.rb:39:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Here is my application.rb
require File.expand_path('../boot', __FILE__)
# Pick the frameworks you want:
# require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "sprockets/railtie"
require "rails/test_unit/railtie"
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
module MongoSt
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# Activate observers that should always be running.
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"
# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]
# Enable the asset pipeline
config.assets.enabled = true
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
end
end
Gemfile :
source 'http://rubygems.org'
gem 'rails', '3.1.1'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.1.4'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'execjs'
gem 'therubyracer'
gem 'jquery-rails'
#mongo db drivers
gem "mongo_mapper"
gem "bson_ext"
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
group :test do
# Pretty printed test output
gem 'turn', :require => false
end
I am new to this environment , so kindly help me in this or provide me any links which will be helpful.
Thanks
I have got the answer for it, Firstly i have created file called 'mongo.yml' in config folder , i have renamed file to 'mongodb.yml'. Its working fine. Basically this file contains details about the connection of database.
mongodb.yml file contain the following code
base: &base
adapter: mongodb
database: test
host: localhost
development:
<<: *base
Related
First, you should know upfront I am a newb to rails so I apologize if this is a dumb mistake but I've been racking my brain on it and thought I'd ask for some help.
I am currently unable to start my local rails server all of the sudden. Not sure what I've done to cause this as I was able to start it earlier today just fine. Only thing I've done in between it working and not was trying to figure out how to push the app to Heroku.
When running rails s while in root of the app I get this error:
/Users/jonathanmacdonald/code/lrbp/config/application.rb:6:in `require': cannot load such file -- active_job/railtie (LoadError)
from /Users/jonathanmacdonald/code/lrbp/config/application.rb:6:in `<top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/railties- 4.2.3/lib/rails/commands/commands_tasks.rb:78:in `require'
from /Library/Ruby/Gems/2.0.0/gems/railties- 4.2.3/lib/rails/commands/commands_tasks.rb:78:in `block in server'
from /Library/Ruby/Gems/2.0.0/gems/railties- 4.2.3/lib/rails/commands/commands_tasks.rb:75:in `tap'
from /Library/Ruby/Gems/2.0.0/gems/railties- 4.2.3/lib/rails/commands/commands_tasks.rb:75:in `server'
from /Library/Ruby/Gems/2.0.0/gems/railties- 4.2.3/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /Library/Ruby/Gems/2.0.0/gems/railties- 4.2.3/lib/rails/commands.rb:17:in `<top (required)>'
from /Users/jonathanmacdonald/code/lrbp/bin/rails:10:in `require'
from /Users/jonathanmacdonald/code/lrbp/bin/rails:10:in `<top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/spring- 1.6.2/lib/spring/client/rails.rb:28:in `load'
from /Library/Ruby/Gems/2.0.0/gems/spring- 1.6.2/lib/spring/client/rails.rb:28:in `call'
from /Library/Ruby/Gems/2.0.0/gems/spring- 1.6.2/lib/spring/client/command.rb:7:in `call'
from /Library/Ruby/Gems/2.0.0/gems/spring- 1.6.2/lib/spring/client.rb:28:in `run'
from /Library/Ruby/Gems/2.0.0/gems/spring-1.6.2/bin/spring:49:in `<top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/spring- 1.6.2/lib/spring/binstub.rb:11:in `load'
from /Library/Ruby/Gems/2.0.0/gems/spring- 1.6.2/lib/spring/binstub.rb:11:in `<top (required)>'
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/jonathanmacdonald/code/lrbp/bin/spring:13:in `<top (required)>'
from bin/rails:4:in `load'
from bin/rails:4:in `<main>'
Gemfile
source 'https://rubygems.org'
group :production do
gem 'rails', '4.2.3'
gem 'pg'
gem 'rails_12factor'
gem 'bootstrap-sass'
end
group :development, :test do
gem 'sqlite3'
gem 'byebug'
gem 'web-console', '~> 2.0'
gem 'spring'
gem 'binding_of_caller'
gem 'better_errors'
end
config/application.rb
require File.expand_path('../boot', __FILE__)
require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
require "sprockets/railtie"
# require "rails/test_unit/railtie"
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Lrbp
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*. {rb,yml}').to_s]
# config.i18n.default_locale = :de
# Do not swallow errors in after_commit/after_rollback callbacks.
config.active_record.raise_in_transactional_callbacks = true
config.assets.initialize_on_precompile = false
end
end
Things I've tried after research
bundle exec rails server ->> Still won't start and produces the exact same error
Temporarily mv Gemfile.lock .. so that I could regenerate it with bundle install ->> No change. Same error.
gem pristine --all ->> No change. Same error.
gem uninstall rails and then afterwards gem install rails ->> No change. Same error.
Setup
OS X 10.11.2
Rails 4.2.3
Ruby 2.0.0
What can I look for or try? Any help is appreciated. Let me know if you need any more information in order to help.
Your application.rb will look like
require File.expand_path('../boot', __FILE__)
require 'rails/all'
Bundler.require(:default, Rails.env)
module Lrbp
class Application < Rails::Application
you do not require to each rails module separately like
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
require "sprockets/railtie"
you can use.
require 'rails/all'
it will do something like this
%w(
active_record
action_controller
action_view
action_mailer
rails/test_unit
sprockets
).each do |framework|
begin
require "#{framework}/railtie"
rescue LoadError
end
end
and Gemfile
source 'https://rubygems.org'
gem 'rails', '4.2.3'
gem 'pg'
gem 'rails_12factor'
gem 'bootstrap-sass'
group :development, :test do
gem 'sqlite3'
gem 'byebug'
gem 'web-console', '~> 2.0'
gem 'spring'
gem 'binding_of_caller'
gem 'better_errors'
end
Then you should do
bundle install & bundle exec rails s
I have finally installed all the required gems for open source project kandan and ruby on rails however whenever I try and run rake db:create I get thrown this error and i'm not sure how to fix it. If anyone could assist me that would be greatly appreciated :)
kandan dan$ rake db:create
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-3.2.21/lib/active_support/values/time_zone.rb:270: warning: circular argument reference - now
rake aborted!
LoadError: cannot load such file -- guard/guard
/Users/dan/kandan/config/application.rb:13:in `<top (required)>'
/Users/dan/kandan/Rakefile:5:in `<top (required)>'
LoadError: cannot load such file -- guard-spork
/Users/dan/kandan/config/application.rb:13:in `<top (required)>'
/Users/dan/kandan/Rakefile:5:in `<top (required)>'
(See full trace by running task with --trace)
For anyone interested in the --trace error:
rake db:create --trace
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-3.2.21/lib/active_support/values/time_zone.rb:270: warning: circular argument reference - now
rake aborted!
LoadError: cannot load such file -- guard/guard
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:251:in `require'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:251:in `block in require'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:236:in `load_dependency'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:251:in `require'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-spork-1.5.1/lib/guard/spork.rb:2:in `<top (required)>'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:85:in `require'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:85:in `rescue in block in require'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:68:in `block in require'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `each'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `require'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler.rb:134:in `require'
/Users/dan/kandan/config/application.rb:13:in `<top (required)>'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Users/dan/kandan/Rakefile:5:in `<top (required)>'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/rake_module.rb:28:in `load'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/rake_module.rb:28:in `load_rakefile'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:689:in `raw_load_rakefile'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:94:in `block in load_rakefile'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:93:in `load_rakefile'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:77:in `block in run'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/Users/dan/.rbenv/versions/2.2.2/bin/rake:33:in `<main>'
LoadError: cannot load such file -- guard-spork
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `require'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `each'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `block in require'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `each'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `require'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler.rb:134:in `require'
/Users/dan/kandan/config/application.rb:13:in `<top (required)>'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Users/dan/kandan/Rakefile:5:in `<top (required)>'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/rake_module.rb:28:in `load'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/rake_module.rb:28:in `load_rakefile'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:689:in `raw_load_rakefile'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:94:in `block in load_rakefile'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:93:in `load_rakefile'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:77:in `block in run'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/Users/dan/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/Users/dan/.rbenv/versions/2.2.2/bin/rake:33:in `<main>'
EDIT
Here is what is in /Users/dan/kandan/config/application.rb
require File.expand_path('../boot', __FILE__)
# Pick the frameworks you want:
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "sprockets/railtie"
# require "rails/test_unit/railtie"
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
require "./lib/kandan_config.rb"
module Kandan
class Application < Rails::Application
# Dealing with Heroku-specific eccentricities
config.assets.initialize_on_precompile = false
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# Activate observers that should always be running.
config.active_record.observers = [:activity_observer, :attachment_observer, :channel_observer, :user_observer]
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"
# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]
config.assets.precompile += ["admin/admin.js", "admin.css"]
# Use SQL instead of Active Record's schema dumper when creating the database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
# config.active_record.schema_format = :sql
# Enforce whitelist mode for mass assignment.
# This will create an empty whitelist of attributes available for mass-assignment for all models
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
# parameters by using an attr_accessible or attr_protected declaration.
config.active_record.whitelist_attributes = true
config.active_record.mass_assignment_sanitizer = :strict
# Enable the asset pipeline
config.assets.enabled = true
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
end
end
EDIT Here is what is in my guardfile
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
guard 'rspec' do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
# Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
# Capybara features specs
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
# Turnip features and steps
watch(%r{^spec/acceptance/(.+)\.feature$})
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
end
guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do
watch('config/application.rb')
watch('config/environment.rb')
watch('config/environments/test.rb')
watch(%r{^config/initializers/.+\.rb$})
watch('Gemfile')
watch('Gemfile.lock')
watch('spec/spec_helper.rb') { :rspec }
watch('test/test_helper.rb') { :test_unit }
watch(%r{features/support/}) { :cucumber }
end
EDIT Here is my gemfile:
source 'https://rubygems.org'
# Core gems
gem 'rails', '~> 3.2.21'
# Database adapters
gem 'pg'
# Uncomment next line when using MySQL database
#gem 'mysql2'
# Auth gems
gem 'devise'
gem 'cancancan', '~> 1.9'
# Server/transport gems
gem 'thin'
gem 'faye'
# Helper gems
gem 'kaminari'
gem 'aws-sdk'
gem 'paperclip'
gem 'remotipart'
gem 'jquery-rails'
gem 'enumerize'
gem 'arel'
gem 'tzinfo'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails'
gem 'coffee-rails'
gem 'bourbon'
gem 'execjs'
gem 'eco'
gem 'uglifier'
gem 'bootstrap-sass', '3.1.1.0'
gem 'sass', '3.2.13'
gem 'gemoji', '~> 1.5.0'
end
group :production do
gem 'kandan-count'
end
group :development do
gem 'kandan-count-dev'
gem 'pry-rails'
gem 'quiet_assets'
gem 'awesome_print'
gem 'better_errors'
gem 'binding_of_caller'
if RUBY_VERSION >= '2.0.0'
gem 'byebug'
else
gem 'debugger'
end
end
group :test do
gem 'faker'
gem 'rspec-rails', '~> 3.1'
gem 'shoulda-matchers'
gem 'factory_girl_rails'
gem 'simplecov', :require => false
gem 'coveralls', :require => false
gem 'poltergeist'
gem 'launchy'
gem 'capybara'
end
group :development, :test do
gem 'sqlite3'
gem 'guard'
gem 'guard-rspec'
gem 'guard-spork'
gem 'database_cleaner'
gem 'jasmine'
end
Based on your Gemfile I can say that you are missing spork in your Gemfile
Edit your Gemfile like this
group :development, :test do
gem 'sqlite3'
gem 'spork', :git => 'git://github.com/sporkrb/spork.git'
gem 'spork-rails'
gem 'guard'
gem 'guard-rspec'
gem 'guard-spork'
gem 'database_cleaner'
gem 'jasmine'
end
Then run bundle install
Initialize it by running in terminal
spork rspec --bootstrap
Re generate your Guardfile by running
guard init rspec
gurad init spork
I'm studying Rails tutorial Chapter 3.
I cannot execute the following command. If you have an idea to solve this problem, please tell me.
Thanks.
exec command
bundle exec rails generate rspec:install
Errors
/Users/mofuty/rails_projects/sample_app/config/application.rb:5:in `require': cannot load such file -- active_job/railtie (LoadError)
from /Users/mofuty/rails_projects/sample_app/config/application.rb:5:in `<top (required)>'
from /Users/mofuty/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.0.5/lib/rails/commands.rb:43:in `require'
from /Users/mofuty/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.0.5/lib/rails/commands.rb:43:in `<top (required)>'
from bin/rails:8:in `require'
from bin/rails:8:in `<main>'
Gemfile
source 'https://rubygems.org'
ruby '2.1.2'
#ruby-gemset=railstutorial_rails_4_0
gem 'rails', '4.0.5'
group :development, :test do
gem 'sqlite3', '1.3.8'
gem 'rspec-rails', '2.13.1'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
end
gem 'sass-rails', '4.0.5'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'
group :doc do
gem 'sdoc', '0.3.20', require: false
end
group :production do
gem 'pg', '0.15.1'
gem 'rails_12factor', '0.0.2'
end
The following is apprication.rb. If you needs more details, please ask me.
config/application.rb
require File.expand_path('../boot', __FILE__)
# Pick the frameworks you want: require "active_model/railtie" require "active_job/railtie" require "active_record/railtie" require "action_controller/railtie" require "action_mailer/railtie" require "action_view/railtie" require "sprockets/railtie"
# require "rails/test_unit/railtie"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production. Bundler.require(*Rails.groups)
module SampleApp class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
# Do not swallow errors in after_commit/after_rollback callbacks.
config.active_record.raise_in_transactional_callbacks = true end end
Try bundle exec rails generate rspec:install
bundle exec is a Bundler command to execute a script in the context of the current bundle (the one from your directory's Gemfile)
It sounds as though your test suite is invoking some code with a dependency on the new ActiveJob framework that is part of Rails 4.
The error suggests that you do not have the railtie included in your config/application.rb file. If you open it, you'll likely find it is commented out, look for a line like this: # require "active_job/railtie"
If so, uncomment it. If that line is not included in the file, add require "active_job/railtie" on a new line after this require "active_model/railtie".
This will ensure that the active job railtie is loaded on Rails initialization.
Thanks for your advice. The problem is I executed rails new with rails 4.2.x. So, I rebuild the project with 4.0.5. Then I could executed bundle exec rails generate rspec:install. I appreciate you.
Novice Ruby on Rails dev here. I recently pulled code from a remote team that was building an iPhone App, including the API for the Rails backend, but once I finished pulling the code, I get the following error in terminal when I try and start the Rails server.
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/bundler-1.1.5/lib/bundler/runtime.rb:68:in `require': can't convert true into String (TypeError)
from /usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/bundler-1.1.5/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/bundler-1.1.5/lib/bundler/runtime.rb:66:in `each'
from /usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/bundler-1.1.5/lib/bundler/runtime.rb:66:in `block in require'
from /usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/bundler-1.1.5/lib/bundler/runtime.rb:55:in `each'
from /usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/bundler-1.1.5/lib/bundler/runtime.rb:55:in `require'
from /usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/bundler-1.1.5/lib/bundler.rb:119:in `require'
from /Users/tmylonas/Sites/getlocal/config/application.rb:7:in `<top (required)>'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands.rb:53:in `require'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands.rb:53:in `block in <top (required)>'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands.rb:50:in `tap'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
And here's the application.rb:
require File.expand_path('../boot', __FILE__)
require 'rails/all'
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
module Getlocal
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Custom directories with classes and modules you want to be autoloadable.
config.autoload_paths += %W(#{config.root}/lib)
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# Activate observers that should always be running.
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"
# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]
# Enable escaping HTML in JSON.
config.active_support.escape_html_entities_in_json = true
# Use SQL instead of Active Record's schema dumper when creating the database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
# config.active_record.schema_format = :sql
# Enforce whitelist mode for mass assignment.
# This will create an empty whitelist of attributes available for mass-assignment for all models
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
# parameters by using an attr_accessible or attr_protected declaration.
config.active_record.whitelist_attributes = true
# Enable the asset pipeline
config.assets.enabled = true
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
config.assets.initialize_on_precompile = false
end
end
And here's the gem file:
source 'https://rubygems.org'
ruby '1.9.3'
gem 'rails', '3.2.8'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'pg'
gem 'devise'
gem 'simple_form'
gem 'thin'
gem 'cancan'
gem 'sidekiq'
gem 'sinatra', require: false
gem 'slim'
gem 'kaminari'
gem 'high_voltage'
gem 'bootbox-rails'
gem 'rails_autolink'
gem 'newrelic_rpm'
gem "active_model_serializers", "~> 0.8.1"
gem 'google_places'
gem 'figaro'
gem 'houston', :require => true
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'underscore-rails'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
group :development, :test do
gem 'pry'
gem 'pry-rails'
end
group :development do
gem 'better_errors'
gem 'binding_of_caller'
gem 'sextant'
end
Unfortunately, the error is very nondescript. I'm not sure if this question is specific enough for SO. If it's not, apologies, but after googling for several hours, reading threads like this one: can't convert true into String and this one: Ruby returns TypeError: can't convert Object into String, where the code is identifiable, I thought I'd see if I could get someone to give me some more specific advice about how to diagnose and ultimately fix this issue.
Thank you much.
As usual, the best way to answer my SO questions is to go through the process of submitting the question, sitting on it for 24 hours and then trying again.
The issue here is that the "Houston" gem, which I'm not familiar with, doesn't appear to work with Ruby 1.9.3. Once I commented that gem out of the gemfile (thanks for Santosh for suggesting I post the gemfile because this is why I looked deeper at it!), the Rails server started right up.
I make a folder in public/images called google-markers but when i go to
http://myproject/images/google-markers/mymarker.png
I got this error :
No route matches "/images/google-markers/mymarker.png"
It seems, i can't use a subfolder of images in my project. When i use direct images in my images folder, everything works fine.
Thank you for help!
ps : I use passenger for deployment, it's a development version on rails 3.0.9
EDIT :
My config.ru :
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run Hotelandlodge::Application
and my development.rb :
Hotelandlodge::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
config.cache_classes = false
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_view.debug_rjs = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false
# Print deprecation notices to the Rails logger
config.active_support.deprecation = :log
Paperclip.options[:command_path] = "/usr/local/bin/"
# Only use best-standards-support built into browsers
config.action_dispatch.best_standards_support = :builtin
end
My config/application.rb :
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# If you have a Gemfile, require the gems listed there, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env) if defined?(Bundler)
module Hotelandlodge
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# Activate observers that should always be running.
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
# JavaScript files you want as :defaults (application.js is always included).
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"
# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]
end
end
My Gemfile :
source 'http://rubygems.org'
gem 'rails', '3.0.9'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2', '< 0.3'
gem "paperclip", "~> 2.4"
gem 'activeadmin'
gem 'will_paginate'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
# gem 'ruby-debug'
# gem 'ruby-debug19', :require => 'ruby-debug'
# Bundle the extra gems:
# gem 'bj'
# gem 'nokogiri'
# gem 'sqlite3-ruby', :require => 'sqlite3'
# gem 'aws-s3', :require => 'aws/s3'
# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
# group :development, :test do
# gem 'webrat'
# end
Did you add the path to routes.rb?