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.
Related
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'm just trying to install ActiveAdmin. Seems pretty straightforward.
http://net.tutsplus.com/tutorials/ruby/create-beautiful-administration-interfaces-with-active-admin/
But when I get to rails generate active_admin:install
I get:
$ rails generate active_admin:install
/home/user/active_admin/config/application.rb:13:in `<module:ActiveAdmin>': superclass mismatch for class Application (TypeError)
from /home/user/active_admin/config/application.rb:12:in `<top (required)>'
from /home/user/.rvm/gems/ruby-1.9.3-p429/gems/railties-3.2.13/lib/rails/commands.rb:24:in `require'
from /home/user/.rvm/gems/ruby-1.9.3-p429/gems/railties-3.2.13/lib/rails/commands.rb:24:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Can't seem to find anyone else with this problem. I even deleted active_admin and started the whole thing again from scratch... no dice.
You need to rename your application, it cannot be named active_admin.
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.
I'm a beginner with Rails and I've been trying to find out what in the world is going wrong here for the past few days but with absolutely no luck. I searched everywhere, but found nothing. Basically, when I run any sort of command line method, I will get a NameError. I have tried running this in different project directories as well that used to work. It seems that rails is just broken...
I am running Win7-32bit using NetBeans 6.9.1 for editing files and cmd.exe for running rails console.
Everything had been working fine for about two weeks and then this started happening suddenly. Here are a few examples:
rails generate model:
irb(main):004:0> rails generate model datatest
NameError: undefined local variable or method `datatest' for main:Object
from (irb):4
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands/console.rb:44:in `start'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands/console.rb:8:in `start'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:23:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
rails generate migration:
irb(main):003:0> rails generate migration rename_password_to_hashed_password
NameError: undefined local variable or method `rename_password_to_hashed_password' for main:Object
from (irb):3
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands/console.rb:44:in `start'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands/console.rb:8:in `start'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:23:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
rake db:migrate:
irb(main):005:0> rake db:migrate
NameError: undefined local variable or method `migrate' for main:Object
from (irb):5
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands/console.rb:44:in `start'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands/console.rb:8:in `start'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:23:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Any sort of help would be VERY appreciated. Thanks!
These commands don't work from within irb, you have to start them directly from cmd.exe.
I would take the initiative of elaborating #dhofset's answer. Basically we use rails app related commands in the console directly and not in the irb console. Even I work on windows so I give you this with few examples
This is what you do
1. Create new App
C:\Users\rohit>rails new_app
2. Generate a scaffold
C:\Users\rohit\new_app>ruby script\generate scaffold User name:string
3. Generate a model
C:\Users\rohit\new_app>ruby script\generate model User name:string
4. To run a rake task
C:\Users\rohit\new_app>rake db:create
C:\Users\rohit\new_app>rake db:migrate
Hope you have a better understanding now.
Yep, dhofstet has it right: these are all commands for the windows prompt, they're not ruby statements.