I am completely new to ror and am following Michael Hartl's tutorial but I keep getting an error when I get to section 1.2.5. using the rails server command. When I use this command (whilst I am in my rail app directory 'first_app') I get the following error
c:\Users\rails_projects\first_app>rails server
c:/rails_projects/first_app/config/application.rb:7:in `<top (required)>': undefined method `groups' for Rails:
Module (NoMethodError)
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.0.11/lib/rails/comma
nds.rb:28:in `require'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.0.11/lib/rails/comma
nds.rb:28:in `block in <top (required)>'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.0.11/lib/rails/comma
nds.rb:27:in `tap'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.0.11/lib/rails/comma
nds.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I can't figure out what went wrong, my bundle installed fine (section 1.2.4).
If your Gemfile is not set to use rails 3.1 or greater, try updating to 3.1.
Related
I am new to ruby on rails. I want to re-create a production setup on my local system for development purposes.I seem to have run into a problem during migration of database.
I am using Ubuntu 18.04 OS. I have installed mysql-server, ruby 2.3.2 , rails 5.0, libmysqld-dev and mysql2 gem successfully. I was able to create a database and import the SQL file for table creation. To do pending migration, I executed rake db:migrate. I am getting the following error.
rake aborted!NameError: uninitialized constant ActiveRecord::VERSION
/home/raj/.rvm/gems/ruby-2.3.2/gems/activerecord-session_store-1.1.1/lib/action_dispatch/session/active_record_store.rb:151:in `<top (required)>'
/home/raj/.rvm/gems/ruby-2.3.2/gems/activerecord-session_store-1.1.1/lib/active_record/session_store.rb:2:in `require'
/home/raj/.rvm/gems/ruby-2.3.2/gems/activerecord-session_store-1.1.1/lib/active_record/session_store.rb:2:in `<top (required)>'
/home/raj/.rvm/gems/ruby-2.3.2/gems/activerecord-session_store-1.1.1/lib/activerecord/session_store.rb:1:in `require'
/home/raj/.rvm/gems/ruby-2.3.2/gems/activerecord-session_store-1.1.1/lib/activerecord/session_store.rb:1:in `<top (required)>'
/home/raj/IRIS/config/application.rb:7:in `<top (required)>'
/home/raj/IRIS/Rakefile:4:in `require'
/home/raj/IRIS/Rakefile:4:in `<top (required)>'
/home/raj/.rvm/gems/ruby-2.3.2/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
/home/raj/.rvm/gems/ruby-2.3.2/bin/ruby_executable_hooks:24:in `eval'
/home/raj/.rvm/gems/ruby-2.3.2/bin/ruby_executable_hooks:24:in `<main>'
LoadError: cannot load such file -- activerecord-session_store
/home/raj/IRIS/config/application.rb:7:in `<top (required)>'
/home/raj/IRIS/Rakefile:4:in `require'
/home/raj/IRIS/Rakefile:4:in `<top (required)>'
/home/raj/.rvm/gems/ruby-2.3.2/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
/home/raj/.rvm/gems/ruby-2.3.2/bin/ruby_executable_hooks:24:in `eval'
/home/raj/.rvm/gems/ruby-2.3.2/bin/ruby_executable_hooks:24:in `<main>'
(See full trace by running task with --trace)
Regarding the error in active_record_store.rb line number 151, the code is as follows:
if ActiveRecord::VERSION::MAJOR == 4
require 'action_dispatch/session/legacy_support'
ActionDispatch::Session::ActiveRecordStore.send(:include, ActionDispatch::Session::LegacySupport)
end
During RVM installation rails latest version was also installed somehow. Removing all the gems and doing bundle install worked.
Try running the below mentioned command
gem install activerecord
Hope this helps.
Can you add this to the top of active_record_store.rb to see if it works?
require 'active_record/version'
I'm really new to Ruby and its Rails framework and I was following a tutorial when I ran into some issues using the rails generate command. I tried using rails generate scaffold and rails generate controller but it didn't work. The full trace is this:
/usr/lib/ruby/vendor_ruby/rails/railtie/configuration.rb:95:in `method_missing': undefined method `load_defaults' for #<Rails::Application::Configuration:0x000055cdba53c180> (NoMethodError)
from /home/eric/Projects/blog/config/application.rb:12:in `<class:Application>'
from /home/eric/Projects/blog/config/application.rb:10:in `<module:Blog>'
from /home/eric/Projects/blog/config/application.rb:9:in `<top (required)>'
from /var/lib/gems/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:92:in `require'
from /var/lib/gems/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:92:in `preload'
from /var/lib/gems/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:153:in `serve'
from /var/lib/gems/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:141:in `block in run'
from /var/lib/gems/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:135:in `loop'
from /var/lib/gems/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:135:in `run'
from /var/lib/gems/2.5.0/gems/spring-2.0.2/lib/spring/application/boot.rb:19:in `<top (required)>'
from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
from -e:1:in `<main>'
I think that the main issue is that I'm missing the 'load_defaults' method, but I couldn't find anything on how to resolve the issue. For context, I'm doing this all on a completely new rails project on Ubuntu - the only things I've done so far are rails new and bundle install.
Somewhat curiously, this issue is only popping up on new rails projects that I've created. I tried using rails generate commands on a project I had earlier and it worked. I couldn't figure out what was different between the projects though.
Any suggestions would be greatly appreciated!
I'm just starting a new rails app but it doesn't let me start the server, after typing 'rails s' the console just pukes me out this;
/Users/user/.rvm/gems/ruby-2.4.1/gems/railties-4.2.9/lib/rails/railtie/configuration.rb:95:in `method_missing': undefined method `load_defaults' for #<Rails::Application::Configuration:0x007fa393f7db20> (NoMethodError)
from /Users/user/Desktop/MiProyecto/Portafolio/config/application.rb:12:in `<class:Application>'
from /Users/user/Desktop/MiProyecto/Portafolio/config/application.rb:10:in `<module:Portafolio>'
from /Users/user/Desktop/MiProyecto/Portafolio/config/application.rb:9:in `<top (required)>'
from /Users/user/.rvm/gems/ruby-2.4.1/gems/railties-4.2.9/lib/rails/commands/commands_tasks.rb:78:in `require'
from /Users/user/.rvm/gems/ruby-2.4.1/gems/railties-4.2.9/lib/rails/commands/commands_tasks.rb:78:in `block in server'
from /Users/user/.rvm/gems/ruby-2.4.1/gems/railties-4.2.9/lib/rails/commands/commands_tasks.rb:75:in `tap'
from /Users/user/.rvm/gems/ruby-2.4.1/gems/railties-4.2.9/lib/rails/commands/commands_tasks.rb:75:in `server'
from /Users/user/.rvm/gems/ruby-2.4.1/gems/railties-4.2.9/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /Users/user/.rvm/gems/ruby-2.4.1/gems/railties-4.2.9/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:9:in `require'
from bin/rails:9:in `<main>'
Any thoughts?
Thanks in advance.
ps: I already ran bundle install and it went out perfectly.
Check in which Rails version you started your application. If by any chance you changed it, upgrading or downgrading it, then, just to be sure, try removing the Gemfile.lock file, adding the "original" Rails version and bundling again.
I reproduced the 'method_missing': undefined method 'load_defaults' error firstly creating a blank Rails application using the 5.1.3 version, and then changing it to the 5.0.1, removing the Gemfile.lock and running bundle.
I get error after I use rails new command-
Pareshs-MacBook-Pro:Desktop psghodge$ rails new lynda_cms
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/rails-2.3.5/lib/rails_generator/options.rb:32:in `default_options': undefined method `write_inheritable_attribute' for Rails::Generator::Base:Class (NoMethodError)
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/rails-2.3.5/lib/rails_generator/base.rb:90:in `<class:Base>'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/rails-2.3.5/lib/rails_generator/base.rb:85:in `<module:Generator>'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/rails-2.3.5/lib/rails_generator/base.rb:48:in `<module:Rails>'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/rails-2.3.5/lib/rails_generator/base.rb:6:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:126:in `require'
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:126:in `require'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/rails-2.3.5/lib/rails_generator.rb:34:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:126:in `require'
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:126:in `require'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/rails-2.3.5/bin/rails:14:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.0.0-p353/bin/rails:23:in `load'
from /usr/local/rvm/gems/ruby-2.0.0-p353/bin/rails:23:in `<main>'
from /usr/local/rvm/gems/ruby-2.0.0-p353/bin/ruby_executable_hooks:15:in `eval'
from /usr/local/rvm/gems/ruby-2.0.0-p353/bin/ruby_executable_hooks:15:in `<main>'
Judging by your error, you're trying to use Rails v2.3.5 with ruby 2.0.0. Without doing a lot of googling I can't be certain, but I'm fairly sure that old versions of Rails like that only work with ruby 1.8.7.
Unless you have a really good reason to use a version of Rails that old, you shouldn't do it.
Use a new Rails, or if you have to use that Rails then install ruby 1.8.7
Working on Mac OS X, trying to learn rails. When I type: "rails generate Scaffold User name:string email:string", I get the following error:
/Users/dnf1991/rails_projects/demo_app/config/application.rb:7:in `<top (required)>': undefined method `groups' for Rails:Module (NoMethodError)
from /Users/dnf1991/.rvm/gems/ruby-1.9.2-p290#rails3tutorial/gems/railties-3.0.9/lib/rails/commands.rb:15:in `require'
from /Users/dnf1991/.rvm/gems/ruby-1.9.2-p290#rails3tutorial/gems/railties-3.0.9/lib/rails/commands.rb:15:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Any thoughts?
I had this exact same problem following the same guide you are. I deleted the project and re-generated, and did not follow the instructions to modify gemfile in the project to use 1.3.3 version of sql (and didn't comment out the other default inclusions) and the error went away.