代码之家  ›  专栏  ›  技术社区  ›  Bad Request

漂亮的发电机宝石出现安装,但仍然不能使用发电机

  •  1
  • Bad Request  · 技术社区  · 14 年前

    我在WinXP中运行Ruby 1.9.2和Rails 3.0.0。我跑了 gem install nifty-generators 从一个新的项目目录中。它说gem 0.4.2版已经成功安装,但是在安装ri和rdoc时出错,所以我再次运行了相同的命令,但是使用了--no ri--no rdoc开关。现在看来安装了漂亮的发电机没有错误,它出现在我的 gem list ,但是当我跑的时候 rails g nifty:layout 上面写着:布局生成器没有找到。 rails g nifty_layout 也不起作用。有人有主意吗?谢谢!

    编辑:按要求产出:

    C:\Documents\Prgm>ruby -v
    ruby 1.9.2p0 (2010-08-18) [i386-mingw32]
    

    我在运行XP,所以没有 which ,但ruby.exe在 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 Settings/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
    

    也, rails g rails generate 在轨道3上。如图所示: http://railscasts.com/episodes/216-generators-in-rails-3 .

    3 回复  |  直到 14 年前
        1
  •  1
  •   DNNX    14 年前

    我的配置和你差不多,@Anita(win XP,rails 3和ruby 1.9.3),还有 rails g nifty:layout 对我来说很管用。

    确保你在跑步 rails g 来自应用程序根目录的命令(即来自 Gemfile 位于)。同时,确保 Gemfile公司 包含以下行: gem 'nifty-generators' .

        2
  •  0
  •   Jakobinsky    14 年前

    请提供以下命令的输出,以便我们可以尝试帮助您:

    • 红宝石-v
    • 哪颗红宝石
    • 宝石环境
    • rails生成

    另外,请注意 rails g nifty_layout 不应该工作,因为它不是正确的语法。


    就我所见一切似乎都很好。你是否可以安装另一个带有生成器的gem,比如回形针,看看它是否添加到生成器列表中。同时,您是否可能安装了多个版本的rails/ruby?

        3
  •  0
  •   Joshua Cheek    14 年前

    引用自 nifty generators github page .

    轨道3

    将Nifty生成器与Rails 3一起使用 你需要把它包括在你的 Gemfile公司。

    gem "nifty-generators"
    

    生成器使用冒号作为 分隔符而不是下划线。

    rails g nifty:layout
    

    Rails 3的支持还处于早期阶段 请发展 report any issues 你找到了。