I'm running Ruby 1.9.2 and Rails 3.0.0 in WinXP. I ran gem install nifty-generators
from inside a new project directory. It said the gem, version 0.4.2, was successfully installed but there was an error installing ri and rdoc, so I ran the same command again but with the --no-ri --no-rdoc switches. Now it appears nifty_generators is installed with no errors, and it shows up in my gem list
, but when I run rails g nifty:layout
it says the nifty:layout generator wasn't found. rails g nifty_layout
also doesn't work. Anyone has ideas? Thanks!
EDIT: Outputs as requested:
C:\Documents\Prgm>ruby -v
ruby 1.9.2p0 (2010-08-18) [i386-mingw32]
I'm running XP, so don't have which
, but ruby.exe is in C:\Ruby192\bin
.
C:\Documents\Prgm>gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.9.2 (2010-08-18 patchlevel 0) [i386-mingw32]
- INSTALLATION DIRECTORY: C:/Ruby192/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: C:/Ruby192/bin/ruby.exe
- EXECUTABLE DIRECTORY: C:/Ruby192/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-mingw32
- GEM PATHS:
- C:/Ruby192/lib/ruby/gems/1.9.1
- C:/Documents and Setti开发者_如何学Gongs/Linh/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
C:\Prgm\Survey_Manager>rails generate
Usage: rails generate GENERATOR [args] [options]
General options:
-h, [--help] # Print generator's options and usage
-p, [--pretend] # Run but do not make any changes
-f, [--force] # Overwrite files that already exist
-s, [--skip] # Skip files that already exist
-q, [--quiet] # Suppress status output
Please choose a generator below.
Rails:
controller
generator
helper
integration_test
mailer
migration
model
observer
performance_test
plugin
resource
scaffold
scaffold_controller
session_migration
stylesheets
Also, rails g
is shorthand for rails generate
in Rails 3. See e.g. here: http://railscasts.com/episodes/216-generators-in-rails-3.
I have almost the same configuration as you, @Anita (win XP, rails 3 and ruby 1.9.3), and rails g nifty:layout
works pretty well for me.
Make sure that you're running rails g
command from the root directory of your app (i.e. from the directory where Gemfile
is located). Also, make sure that your Gemfile
contains this line: gem 'nifty-generators'
.
Please provide the output of the following commands so we could try and help you:
- ruby -v
- which ruby
- gem env
- rails generate
Also, note that rails g nifty_layout
should not work as it's not the right syntax.
Everything seems alright as far as I can see. would you be able to install another gem with a generator, such as paperclip and see if it's add to your generator list. as well could it be possible that you have more than one version of rails/ruby installed ?
Quoted from the nifty generators github page.
Rails 3
To use Nifty Generators with Rails 3 you will need to include it in your Gemfile.
gem "nifty-generators"
The generators use a colon as the separator instead of an underscore.
rails g nifty:layout
The Rails 3 support is still in early development, please report any issues you find.
精彩评论