rails generate - "Could not find generator" - ruby-on-rails

I am following the Ruby on Rails tutorial by Michael Hartl. In section 6.3.1, I am trying to generate a migration file to add a Password field to my user model. Here is the code that I run:
rails generate add_passsword_digest_to_users password_digest:string
but this throws the error: Could not find generator add_passsword_digest_to_users.
i have used the rails generate command before and it worked perfectly. I'm not sure why I am getting this problem now.
version: Rails 3.2.8, ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]

Try:
rails generate migration add_passsword_digest_to_users password_digest:string
You simply forgot migration which is the generator to use for the other arguments.

You have forget to include migration in the command. You can simply do
rails generate migration add_passsword_digest_to_users password_digest:string

Related

Error: No such file or directory, when trying to execute [ruby script/generate]?

I am writing a small blog application using Rails. I am using Aptana Studio.
When I try to execute:
ruby script/generate scaffold post title:string body:text
from either Aptana Studio or going to the project folder and executing it from the shell, I get this error:
c:\Ruby200\bin\ruby.exe: No such file or directory -- script/generate (LoadError
)
I think you are meaning to do rails generate?
First create a new Rails app:
rails new random_app
cd random_app
rails generate scaffold post title:string body:text
When you "ruby" something, it looks for a file to execute.
Rails is the framework for abstraction and scaffolding.
See "Why does Ruby "script/generate" return "No such file or directory"?".
Rails 3 is the problem. Since Rails 3, all of the "script/whatever" commands have been replaced with "rails whatever".
So now you want rails generate ... or rails server instead.

rails generate ckeditor:install for rails 2.3?

I'm trying to install and set up this gem - https://github.com/galetahub/ckeditor, but when I follow the instructions and run:
rails generate ckeditor:install
I get an error because "rails generate" is a rails 3 command (I think?!).. so my question is, what is the equivalent rails 2 command to run this?
ruby script/generate ckeditor:install
This should do it in Rails 2
Sven

Textmate and Rails (Rails3) not working for "Call Generate Script"

Problem:
The rails UI interface for generating scripts bundle in Textmate is not working.
Description:
In a rails document:"Bundles"> "Ruby on Rails"> "Call Generate Script" and choose "Controller" then type"index" > "index" and submit.A window appears telling me: "Done Generating controller".Yet when I browse through my directories nothing new has been created.
Screenshot:
I take a screenshot of what happens during the generation process:
http://img152.imageshack.us/i/capturedcran20110201003.png/
Versions:
ruby -v: ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
rails -v: Rails 3.0.3
I tried the same with an RVM environment by following this tutorial:
(http://rvm.beginrescueend.com/integration/textmate/)
The result is the same.
Regards,
Guillaume.
You have to slightly modifiy the bundle to make it work with the Rails 3 generate scripts. Have a look at my modifications on GitHub:
https://github.com/dhoelzgen/ruby-on-rails-tmbundle
The error there says that there's "No such file or directory -- script/generate". This leads me to beleive that you're using Rails 3, where the command is now rails generate or rails g for short. Upgrade your Ruby on Rails TextMate bundle (follow the instructions on the GitHub Page) or alternatively run rails g controller [name] from the command line.

Why does Ruby "script/generate" return "No such file or directory"?

I am having trouble using script/generate. I am following the tree based navigation tutorial, which says to use script/plugin install git://github.com/rails/acts_as_tree.git or script/generate nifty_layout.
I keep getting:
No such file or directory -- script/plugin
I've tried these variations:
script/generate nifty_layout
rails generate nifty_layout
ruby script/generate nifty_layout
ruby generate nifty_layout
and they all tell me:
-bash: script/generate: No such file or directory
Am I missing something? Total ruby nuby here and I just can't seem to find an answer.
edit: rails 3 on Mac OS X 10.6
Rails 3 is your problem (or rather the cause of). Since rails 3 all of the "script/whatever" commands have been replaced with "rails whatever".
So now you want "rails generate ..." or "rails server" instead.
Be sure to watch version numbers or post dates when looking at tutorials :)
linkage:
Missing script/generate in Rails 3
There is a LOT of out-of-date information on the interwebs for Rails now as a result of it evolving quickly and being so popular. I use the Ruby on Rails Guides as my first stop for information as those pages seem to be the most current.
The rails generate info seems current.
you may try a couple things, first, make sure since you are using rails 3 that you have run 'bundle install'. depending on how you installed rails and which version of bundler you are using, it may not be finding your rails binary to execute the rails generate .. so you may try prefixing it with bundle exec rails g but that is deprecated and you should get a warning if you call it. Also, make sure you are following ryan's instructions for rails 3 (and run bundle install once you add to the gemfile) on his library: https://github.com/ryanb/nifty-generators
As a shortcut to rails server, you can use 'rails s'. Similarly for the console, 'rails c'.

Missing script/generate in Rails 3

I just installed Rails 3 and created my first app. The install of Rails3 + ruby 1.9 went very smoothly but I am missing the generate script in script/generate.
I have created a new app from scratch with no options to verify.
Any idea why this is happening and how to fix it?
all script/* commands has been removed from rails 3. You should use rails generate or rails g instead of script/generate, rails server or rails s instead of script/server and so on.
try
rails generate ...
the only script existing now is rails all others will be called as parameter of rails.
Take a look a the Ruby on Rails Guides: Getting Started with Rails

Resources