Cannot generate controller via (it doesn't appear in /app/controllers/) rails generate controller StaticPages
Output:
azureuser#host:~/railstutorial_apps/demo$ rails generate controller StaticPages --no-test-framework
/home/azureuser/.rvm/gems/ruby-2.0.0-p643#railstutorial_gemset/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:in `load': /home/azureuser/railstutorial_
/home/azureuser/.rvm/gems/ruby-2.0.0-p643#railstutorial_gemset/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:in `load': /home/azureuser/railst[0/1427]
apps/demo/config/initializers/session_store.rb:1: syntax error, unexpected keyword_when, expecting end-of-input
ure to restart your server when you modify this file.
^ (SyntaxError)
from /home/azureuser/.rvm/gems/ruby-2.0.0-p643#railstutorial_gemset/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:in `block in load'
from /home/azureuser/.rvm/gems/ruby-2.0.0-p643#railstutorial_gemset/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:in `load_dependency'
from /home/azureuser/.rvm/gems/ruby-2.0.0-p643#railstutorial_gemset/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:in `load'
from /home/azureuser/.rvm/gems/ruby-2.0.0-p643#railstutorial_gemset/gems/railties-4.2.3/lib/rails/engine.rb:652:in `block in load_config_initializer'
from /home/azureuser/.rvm/gems/ruby-2.0.0-p643#railstutorial_gemset/gems/activesupport-4.2.3/lib/active_support/notifications.rb:166:in `instrument'
from /home/azureuser/.rvm/gems/ruby-2.0.0-p643#railstutorial_gemset/gems/railties-4.2.3/lib/rails/engine.rb:651:in `load_config_initializer'
from /home/azureuser/.rvm/gems/ruby-2.0.0-p643#railstutorial_gemset/gems/railties-4.2.3/lib/rails/engine.rb:616:in `block (2 levels) in <class:Engine>'
from /home/azureuser/.rvm/gems/ruby-2.0.0-p643#railstutorial_gemset/gems/railties-4.2.3/lib/rails/engine.rb:615:in `each'
from /home/azureuser/.rvm/gems/ruby-2.0.0-p643#railstutorial_gemset/gems/railties-4.2.3/lib/rails/engine.rb:615:in `block in <class:Engine>'
from /home/azureuser/.rvm/gems/ruby-2.0.0-p643#railstutorial_gemset/gems/railties-4.2.3/lib/rails/initializable.rb:30:in `instance_exec'
from /home/azureuser/.rvm/gems/ruby-2.0.0-p643#railstutorial_gemset/gems/railties-4.2.3/lib/rails/initializable.rb:30:in `run'
from /home/azureuser/.rvm/gems/ruby-2.0.0-p643#railstutorial_gemset/gems/railties-4.2.3/lib/rails/initializable.rb:55:in `block in run_initializers'
from /home/azureuser/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'
from /home/azureuser/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
from /home/azureuser/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/tsort.rb:210:in `block (2 levels) in each_strongly_connected_component_from'
from /home/azureuser/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'
from /home/azureuser/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/tsort.rb:209:in `block in each_strongly_connected_component_from'
from /home/azureuser/.rvm/gems/ruby-2.0.0-p643#railstutorial_gemset/gems/railties-4.2.3/lib/rails/initializable.rb:44:in `each'
from /home/azureuser/.rvm/gems/ruby-2.0.0-p643#railstutorial_gemset/gems/railties-4.2.3/lib/rails/initializable.rb:44:in `tsort_each_child'
from /home/azureuser/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/tsort.rb:203:in `each_strongly_connected_component_from'
from /home/azureuser/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'
from /home/azureuser/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/tsort.rb:180:in `each'
from /home/azureuser/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'
from /home/azureuser/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
from /home/azureuser/.rvm/gems/ruby-2.0.0-p643#railstutorial_gemset/gems/railties-4.2.3/lib/rails/initializable.rb:54:in `run_initializers'
from /home/azureuser/.rvm/gems/ruby-2.0.0-p643#railstutorial_gemset/gems/railties-4.2.3/lib/rails/application.rb:352:in `initialize!'
from /home/azureuser/railstutorial_apps/demo/config/environment.rb:5:in `<top (required)>'
from /home/azureuser/.rvm/gems/ruby-2.0.0-p643#railstutorial_gemset/gems/spring-1.3.6/lib/spring/application.rb:92:in `require'
from /home/azureuser/.rvm/gems/ruby-2.0.0-p643#railstutorial_gemset/gems/spring-1.3.6/lib/spring/application.rb:92:in `preload'
from /home/azureuser/.rvm/gems/ruby-2.0.0-p643#railstutorial_gemset/gems/spring-1.3.6/lib/spring/application.rb:143:in `serve'
from /home/azureuser/.rvm/gems/ruby-2.0.0-p643#railstutorial_gemset/gems/spring-1.3.6/lib/spring/application.rb:131:in `block in run'
from /home/azureuser/.rvm/gems/ruby-2.0.0-p643#railstutorial_gemset/gems/spring-1.3.6/lib/spring/application.rb:125:in `loop'
from /home/azureuser/.rvm/gems/ruby-2.0.0-p643#railstutorial_gemset/gems/spring-1.3.6/lib/spring/application.rb:125:in `run'
from /home/azureuser/.rvm/gems/ruby-2.0.0-p643#railstutorial_gemset/gems/spring-1.3.6/lib/spring/application/boot.rb:18:in `<top (required)>'
from /home/azureuser/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/azureuser/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from -e:1:in `<main>'
azureuser#host:~/railstutorial_apps/demo$
As per my comment, there is an error in the config/initializers/session_store.rb. After you fix this error you will be able to generate the controller.
Related
I've juste updated the sidekiq gem to 5.0.4, and now I have this error when I run my server.
NameError: uninitialized constant Sidekiq::Extensions::ActionMailer
/Users/mike/Documents/paycar/back_end/config/initializers/mail.rb:15:in `<top (required)>'
/Users/mike/.rvm/gems/ruby-2.3.1#paycar-api/gems/railties-4.2.7.1/lib/rails/engine.rb:652:in `block in load_config_initializer'
/Users/mike/.rvm/gems/ruby-2.3.1#paycar-api/gems/activesupport-4.2.7.1/lib/active_support/notifications.rb:166:in `instrument'
/Users/mike/.rvm/gems/ruby-2.3.1#paycar-api/gems/railties-4.2.7.1/lib/rails/engine.rb:651:in `load_config_initializer'
/Users/mike/.rvm/gems/ruby-2.3.1#paycar-api/gems/railties-4.2.7.1/lib/rails/engine.rb:616:in `block (2 levels) in <class:Engine>'
/Users/mike/.rvm/gems/ruby-2.3.1#paycar-api/gems/railties-4.2.7.1/lib/rails/engine.rb:615:in `each'
/Users/mike/.rvm/gems/ruby-2.3.1#paycar-api/gems/railties-4.2.7.1/lib/rails/engine.rb:615:in `block in <class:Engine>'
/Users/mike/.rvm/gems/ruby-2.3.1#paycar-api/gems/railties-4.2.7.1/lib/rails/initializable.rb:30:in `instance_exec'
/Users/mike/.rvm/gems/ruby-2.3.1#paycar-api/gems/railties-4.2.7.1/lib/rails/initializable.rb:30:in `run'
/Users/mike/.rvm/gems/ruby-2.3.1#paycar-api/gems/railties-4.2.7.1/lib/rails/initializable.rb:55:in `block in run_initializers'
/Users/mike/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each'
/Users/mike/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
/Users/mike/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
/Users/mike/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from'
/Users/mike/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
/Users/mike/.rvm/gems/ruby-2.3.1#paycar-api/gems/railties-4.2.7.1/lib/rails/initializable.rb:44:in `each'
/Users/mike/.rvm/gems/ruby-2.3.1#paycar-api/gems/railties-4.2.7.1/lib/rails/initializable.rb:44:in `tsort_each_child'
/Users/mike/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:415:in `call'
/Users/mike/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:415:in `each_strongly_connected_component_from'
/Users/mike/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component'
/Users/mike/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `each'
/Users/mike/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `call'
/Users/mike/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component'
/Users/mike/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each'
/Users/mike/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each'
/Users/mike/.rvm/gems/ruby-2.3.1#paycar-api/gems/railties-4.2.7.1/lib/rails/initializable.rb:54:in `run_initializers'
/Users/mike/.rvm/gems/ruby-2.3.1#paycar-api/gems/railties-4.2.7.1/lib/rails/application.rb:352:in `initialize!'
/Users/mike/Documents/paycar/back_end/config/environment.rb:6:in `<top (required)>'
/Users/mike/Documents/paycar/back_end/spec/rails_helper.rb:5:in `require'
/Users/mike/Documents/paycar/back_end/spec/rails_helper.rb:5:in `<top (required)>'
/Users/mike/Documents/paycar/back_end/spec/controllers/api/csrf_controller_spec.rb:2:in `require'
/Users/mike/Documents/paycar/back_end/spec/controllers/api/csrf_controller_spec.rb:2:in `<top (required)>'
/Users/mike/.rvm/gems/ruby-2.3.1#paycar-api/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1226:in `load'
/Users/mike/.rvm/gems/ruby-2.3.1#paycar-api/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1226:in `block in load_spec_files'
/Users/mike/.rvm/gems/ruby-2.3.1#paycar-api/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1224:in `each'
/Users/mike/.rvm/gems/ruby-2.3.1#paycar-api/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1224:in `load_spec_files'
/Users/mike/.rvm/gems/ruby-2.3.1#paycar-api/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:97:in `setup'
/Users/mike/.rvm/gems/ruby-2.3.1#paycar-api/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:85:in `run'
/Users/mike/.rvm/gems/ruby-2.3.1#paycar-api/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:70:in `run'
/Users/mike/.rvm/gems/ruby-2.3.1#paycar-api/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:38:in `invoke'
/Users/mike/.rvm/gems/ruby-2.3.1#paycar-api/gems/rspec-core-3.2.3/exe/rspec:4:in `<top (required)>'
/Users/mike/.rvm/gems/ruby-2.3.1#paycar-api/bin/rspec:22:in `load'
/Users/mike/.rvm/gems/ruby-2.3.1#paycar-api/bin/rspec:22:in `<top (required)>'
now line 15 in mail.rb is this
::MandrillMailer::TemplateMailer.extend(Sidekiq::Extensions::ActionMailer)
I've tried adding config.eager_loading = true and also tried to add the classes config.autoload_paths but that didn't help.
Any help would be greatly appreciated.
It might be a file ordering thing. You can see that Sidekiq::Extensions::ActionMailer is defined at https://github.com/mperham/sidekiq/blob/master/lib/sidekiq/extensions/action_mailer.rb. Perhaps try adding a require 'sidekiq/extensions/action_mailer' line at the top?
See "The Delayed Extensions..."
https://github.com/mperham/sidekiq/blob/master/5.0-Upgrade.md#whats-new
Something was broken and now no one generator is not works but i'm nothing change after i'm using rails generator last time. That's i got in a console
/home/sanua/ct/config/initializers/new_framework_defaults.rb:15:in `<top (required)>': undefined method `to_time_preserves_timezone=' for ActiveSupport:Module (NoMethodError)
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:268:in `load'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:268:in `block in load'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:240:in `load_dependency'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:268:in `load'
from /usr/lib/ruby/vendor_ruby/rails/engine.rb:652:in `block in load_config_initializer'
from /usr/lib/ruby/vendor_ruby/active_support/notifications.rb:166:in `instrument'
from /usr/lib/ruby/vendor_ruby/rails/engine.rb:651:in `load_config_initializer'
from /usr/lib/ruby/vendor_ruby/rails/engine.rb:616:in `block (2 levels) in <class:Engine>'
from /usr/lib/ruby/vendor_ruby/rails/engine.rb:615:in `each'
from /usr/lib/ruby/vendor_ruby/rails/engine.rb:615:in `block in <class:Engine>'
from /usr/lib/ruby/vendor_ruby/rails/initializable.rb:30:in `instance_exec'
from /usr/lib/ruby/vendor_ruby/rails/initializable.rb:30:in `run'
from /usr/lib/ruby/vendor_ruby/rails/initializable.rb:55:in `block in run_initializers'
from /usr/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each'
from /usr/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
from /usr/lib/ruby/2.3.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
from /usr/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from'
from /usr/lib/ruby/2.3.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
from /usr/lib/ruby/vendor_ruby/rails/initializable.rb:44:in `each'
from /usr/lib/ruby/vendor_ruby/rails/initializable.rb:44:in `tsort_each_child'
from /usr/lib/ruby/2.3.0/tsort.rb:415:in `call'
from /usr/lib/ruby/2.3.0/tsort.rb:415:in `each_strongly_connected_component_from'
from /usr/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component'
from /usr/lib/ruby/2.3.0/tsort.rb:347:in `each'
from /usr/lib/ruby/2.3.0/tsort.rb:347:in `call'
from /usr/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component'
from /usr/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each'
from /usr/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each'
from /usr/lib/ruby/vendor_ruby/rails/initializable.rb:54:in `run_initializers'
from /usr/lib/ruby/vendor_ruby/rails/application.rb:352:in `initialize!'
from /home/sanua/ct/config/environment.rb:5:in `<top (required)>'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:274:in `require'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:274:in `block in require'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:240:in `load_dependency'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:274:in `require'
from /usr/lib/ruby/vendor_ruby/spring/application.rb:92:in `preload'
from /usr/lib/ruby/vendor_ruby/spring/application.rb:143:in `serve'
from /usr/lib/ruby/vendor_ruby/spring/application.rb:131:in `block in run'
from /usr/lib/ruby/vendor_ruby/spring/application.rb:125:in `loop'
from /usr/lib/ruby/vendor_ruby/spring/application.rb:125:in `run'
from /usr/lib/ruby/vendor_ruby/spring/application/boot.rb:18:in `<top (required)>'
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'/home/sanua/ct/config/initializers/new_framework_defaults.rb:15:in `<top (required)>': undefined method `to_time_preserves_timezone=' for ActiveSupport:Module (NoMethodError)
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:268:in `load'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:268:in `block in load'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:240:in `load_dependency'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:268:in `load'
from /usr/lib/ruby/vendor_ruby/rails/engine.rb:652:in `block in load_config_initializer'
from /usr/lib/ruby/vendor_ruby/active_support/notifications.rb:166:in `instrument'
from /usr/lib/ruby/vendor_ruby/rails/engine.rb:651:in `load_config_initializer'
from /usr/lib/ruby/vendor_ruby/rails/engine.rb:616:in `block (2 levels) in <class:Engine>'
from /usr/lib/ruby/vendor_ruby/rails/engine.rb:615:in `each'
from /usr/lib/ruby/vendor_ruby/rails/engine.rb:615:in `block in <class:Engine>'
from /usr/lib/ruby/vendor_ruby/rails/initializable.rb:30:in `instance_exec'
from /usr/lib/ruby/vendor_ruby/rails/initializable.rb:30:in `run'
from /usr/lib/ruby/vendor_ruby/rails/initializable.rb:55:in `block in run_initializers'
from /usr/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each'
from /usr/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
from /usr/lib/ruby/2.3.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
from /usr/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from'
from /usr/lib/ruby/2.3.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
from /usr/lib/ruby/vendor_ruby/rails/initializable.rb:44:in `each'
from /usr/lib/ruby/vendor_ruby/rails/initializable.rb:44:in `tsort_each_child'
from /usr/lib/ruby/2.3.0/tsort.rb:415:in `call'
from /usr/lib/ruby/2.3.0/tsort.rb:415:in `each_strongly_connected_component_from'
from /usr/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component'
from /usr/lib/ruby/2.3.0/tsort.rb:347:in `each'
from /usr/lib/ruby/2.3.0/tsort.rb:347:in `call'
from /usr/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component'
from /usr/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each'
from /usr/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each'
from /usr/lib/ruby/vendor_ruby/rails/initializable.rb:54:in `run_initializers'
from /usr/lib/ruby/vendor_ruby/rails/application.rb:352:in `initialize!'
from /home/sanua/ct/config/environment.rb:5:in `<top (required)>'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:274:in `require'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:274:in `block in require'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:240:in `load_dependency'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:274:in `require'
from /usr/lib/ruby/vendor_ruby/spring/application.rb:92:in `preload'
from /usr/lib/ruby/vendor_ruby/spring/application.rb:143:in `serve'
from /usr/lib/ruby/vendor_ruby/spring/application.rb:131:in `block in run'
from /usr/lib/ruby/vendor_ruby/spring/application.rb:125:in `loop'
from /usr/lib/ruby/vendor_ruby/spring/application.rb:125:in `run'
from /usr/lib/ruby/vendor_ruby/spring/application/boot.rb:18:in `<top (required)>'
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'
I constantly see this message whatever i write(rails generate controller, model...)
you need to delete the Gemfile.lock and bundle install after that, as the correct version will then be fetched.
#TRIGUN117 I would suggest you to create a new rails app since its a problem with initializer. I believe something is corrupted in your app.
Perhaps you just have an incompatible version of active_support. If you do not belong on gem versions, simply delete Gemfile.lock and execute bundle to update gems and regenerate the Gemfile.lock. If you do, or problem still exists, look through Gemfile and make sure that all rails' gems have the same version specified.
I'm trying to add some functionality to the ENV class of a Rails 4 App.
My initializer at config/initializers/env_extend.rb looks like this:
class ENV
def self.enabled?(env_key)
if ENV[env_key].nil?
return false
else
return ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include?(ENV[env_key])
end
end
end
Yet when I load the app with rails console it won't load, and the following is printed out
[mveksler:...web/lib/core_extensions/ENV]$ cd ~/Developer/referral-web
/Users/mveksler/Developer/referral-web/config/initializers/env_extend.rb:1:in `<top (required)>': ENV is not a class (TypeError)
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `load'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `block in load'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `load'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/engine.rb:652:in `block in load_config_initializer'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/notifications.rb:166:in `instrument'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/engine.rb:651:in `load_config_initializer'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/engine.rb:616:in `block (2 levels) in <class:Engine>'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/engine.rb:615:in `each'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/engine.rb:615:in `block in <class:Engine>'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/initializable.rb:30:in `run'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/initializable.rb:44:in `each'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/initializable.rb:44:in `tsort_each_child'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:415:in `call'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:415:in `each_strongly_connected_component_from'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/initializable.rb:44:in `each'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/initializable.rb:44:in `tsort_each_child'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:415:in `call'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:415:in `each_strongly_connected_component_from'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `each'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `call'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component'%
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/application.rb:352:in `initialize!'
from /Users/mveksler/Developer/referral-web/config/environment.rb:5:in `<top (required)>'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `block in require'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.1/lib/spring/application.rb:92:in `preload'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.1/lib/spring/application.rb:143:in `serve'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.1/lib/spring/application.rb:131:in `block in run'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.1/lib/spring/application.rb:125:in `loop'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.1/lib/spring/application.rb:125:in `run'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.1/lib/spring/application/boot.rb:19:in `<top (required)>'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/mveksler/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'
What could be the reason for this?
ENV is not a class (or a module) it is a constant. This should work
def ENV.enabled?(env_key)
if ENV[env_key].nil?
return false
else
return ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include?(ENV[env_key])
end
end
but I am not sure what you are trying to achieve. Are you just trying to call .enabled? on ENV
Edit: I should add that Classes and Module are also constants but my point is that it is not a Class or Module.
Again I have a problem.
In chapter 6 Rails 4 in Action I generated Devise views with rails g devise:views and it was OK. Then I made some changes in .html files and wanted to run bundle exec rspec and got this error:
$ bundle exec rspec
bundler: failed to load command: rspec (/usr/local/bin/rspec)
NameError: uninitialized constant Devise
/home/rafal/ruby_workspace/ticketee/config/initializers/devise.rb:3:in `<top (required)>'
/usr/lib/ruby/vendor_ruby/rails/engine.rb:652:in `block in load_config_initializer'
/var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/notifications.rb:166:in `instrument'
/usr/lib/ruby/vendor_ruby/rails/engine.rb:651:in `load_config_initializer'
/usr/lib/ruby/vendor_ruby/rails/engine.rb:616:in `block (2 levels) in <class:Engine>'
/usr/lib/ruby/vendor_ruby/rails/engine.rb:615:in `each'
/usr/lib/ruby/vendor_ruby/rails/engine.rb:615:in `block in <class:Engine>'
/usr/lib/ruby/vendor_ruby/rails/initializable.rb:30:in `instance_exec'
/usr/lib/ruby/vendor_ruby/rails/initializable.rb:30:in `run'
/usr/lib/ruby/vendor_ruby/rails/initializable.rb:55:in `block in run_initializers'
/usr/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each'
/usr/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
/usr/lib/ruby/2.3.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
/usr/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from'
/usr/lib/ruby/2.3.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
/usr/lib/ruby/vendor_ruby/rails/initializable.rb:44:in `each'
/usr/lib/ruby/vendor_ruby/rails/initializable.rb:44:in `tsort_each_child'
/usr/lib/ruby/2.3.0/tsort.rb:415:in `call'
/usr/lib/ruby/2.3.0/tsort.rb:415:in `each_strongly_connected_component_from'
/usr/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component'
/usr/lib/ruby/2.3.0/tsort.rb:347:in `each'
/usr/lib/ruby/2.3.0/tsort.rb:347:in `call'
/usr/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component'
/usr/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each'
/usr/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each'
/usr/lib/ruby/vendor_ruby/rails/initializable.rb:54:in `run_initializers'
/usr/lib/ruby/vendor_ruby/rails/application.rb:352:in `initialize!'
/home/rafal/ruby_workspace/ticketee/config/environment.rb:5:in `<top (required)>'
/home/rafal/ruby_workspace/ticketee/spec/rails_helper.rb:4:in `require'
/home/rafal/ruby_workspace/ticketee/spec/rails_helper.rb:4:in `<top (required)>'
/home/rafal/ruby_workspace/ticketee/spec/controllers/projects_controller_spec.rb:1:in `require'
/home/rafal/ruby_workspace/ticketee/spec/controllers/projects_controller_spec.rb:1:in `<top (required)>'
/var/lib/gems/2.3.0/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1226:in `load'
/var/lib/gems/2.3.0/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1226:in `block in load_spec_files'
/var/lib/gems/2.3.0/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1224:in `each'
/var/lib/gems/2.3.0/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1224:in `load_spec_files'
/var/lib/gems/2.3.0/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:97:in `setup'
/var/lib/gems/2.3.0/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:85:in `run'
/var/lib/gems/2.3.0/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:70:in `run'
/var/lib/gems/2.3.0/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:38:in `invoke'
/var/lib/gems/2.3.0/gems/rspec-core-3.2.3/exe/rspec:4:in `<top (required)>'
/usr/local/bin/rspec:23:in `load'
/usr/local/bin/rspec:23:in `<top (required)>'
Could you help me?
The problem is that rspec doesn't load devise, to fix it, in your spec/rails_helper.rb file add require devise after require 'rspec/rails'
I am trying to set up rails_rspec with devise.
When I run: rspec all the tests run fine.
When I try with bundle exec rspec I get: config/initializers/devise.rb:3:in `': uninitialized constant Devise (NameError)
The error happens in the initializer file, I have devise in my gemfile. I'm using rails 4 with Devise version 3.4.1 and Rspec version 3.2.0.
Here's the full trace:
/Users/glesauteur/Marc/gigmarket/config/initializers/devise.rb:3:in `<top (required)>': uninitialized constant Devise (NameError)
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/engine.rb:652:in `block in load_config_initializer'
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/notifications.rb:166:in `instrument'
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/engine.rb:651:in `load_config_initializer'
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/engine.rb:616:in `block (2 levels) in <class:Engine>'
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/engine.rb:615:in `each'
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/engine.rb:615:in `block in <class:Engine>'
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/initializable.rb:30:in `run'
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/2.2.0/tsort.rb:226:in `block in tsort_each'
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/2.2.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/2.2.0/tsort.rb:420:in `block (2 levels) in each_strongly_connected_component_from'
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/2.2.0/tsort.rb:429:in `each_strongly_connected_component_from'
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/2.2.0/tsort.rb:419:in `block in each_strongly_connected_component_from'
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/initializable.rb:44:in `each'
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/initializable.rb:44:in `tsort_each_child'
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/2.2.0/tsort.rb:413:in `call'
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/2.2.0/tsort.rb:413:in `each_strongly_connected_component_from'
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/2.2.0/tsort.rb:347:in `block in each_strongly_connected_component'
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/2.2.0/tsort.rb:345:in `each'
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/2.2.0/tsort.rb:345:in `call'
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/2.2.0/tsort.rb:345:in `each_strongly_connected_component'
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/2.2.0/tsort.rb:224:in `tsort_each'
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/2.2.0/tsort.rb:203:in `tsort_each'
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/application.rb:352:in `initialize!'
from /Users/glesauteur/Marc/gigmarket/config/environment.rb:5:in `<top (required)>'
from /Users/glesauteur/Marc/gigmarket/spec/rails_helper.rb:4:in `require'
from /Users/glesauteur/Marc/gigmarket/spec/rails_helper.rb:4:in `<top (required)>'
from /Users/glesauteur/Marc/gigmarket/spec/models/client_spec.rb:1:in `require'
from /Users/glesauteur/Marc/gigmarket/spec/models/client_spec.rb:1:in `<top (required)>'
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1226:in `load'
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1226:in `block in load_spec_files'
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1224:in `each'
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1224:in `load_spec_files'
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:97:in `setup'
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:85:in `run'
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:70:in `run'
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:38:in `invoke'
from /Users/glesauteur/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/rspec-core-3.2.3/exe/rspec:4:in `<top (required)>'
from /Users/glesauteur/.rbenv/versions/2.2.1/bin/rspec:23:in `load'
from /Users/glesauteur/.rbenv/versions/2.2.1/bin/rspec:23:in `<main>'