【问题标题】:Rails scaffolding not generating options menu appearsRails 脚手架不生成选项菜单出现
【发布时间】:2014-01-11 08:16:22
【问题描述】:

这是我所做的一步一步。

cd ~/rails_projects 
rails new demo_app1
cd demo_app1

(将我的 gem 文件修改为 rails 3.2.13。Ssqlite3 到 1.3.5 sass-rails 到 3.2.4 coffee rails 到 3.2.2 uglier 到 1.2.3 jquery-rails 到 2.0.1 和 pg 到 0.12.2 )

然后包更新

bundle install --without production

git init
git add .
git commit -m "initial commit"

然后rails生成脚手架用户名:字符串邮箱:字符串

但它不会生成脚手架,我得到的只是下面发布的选项菜单。

Chris-Schusters-MacBook-Pro:demo_app1 schust49$ rails generate scaffold user name:string email:string
Usage:
  rails new APP_PATH [options]

Options:
  -r, [--ruby=PATH]              # Path to the Ruby binary of your choice
                                 # Default: /Users/schust49/.rvm/rubies/ruby-1.9.3-p484/bin/ruby
  -b, [--builder=BUILDER]        # Path to a application builder (can be a filesystem path or URL)
  -m, [--template=TEMPLATE]      # Path to an application template (can be a filesystem path or URL)
      [--skip-gemfile]           # Don't create a Gemfile
      [--skip-bundle]            # Don't run bundle install
  -G, [--skip-git]               # Skip Git ignores and keeps
  -O, [--skip-active-record]     # Skip Active Record files
  -S, [--skip-sprockets]         # Skip Sprockets files
  -d, [--database=DATABASE]      # Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/frontbase/ibm_db/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc)
                                 # Default: sqlite3
  -j, [--javascript=JAVASCRIPT]  # Preconfigure for selected JavaScript library
                                 # Default: jquery
  -J, [--skip-javascript]        # Skip JavaScript files
      [--dev]                    # Setup the application with Gemfile pointing to your Rails checkout
      [--edge]                   # Setup the application with Gemfile pointing to Rails repository
  -T, [--skip-test-unit]         # Skip Test::Unit files
      [--old-style-hash]         # Force using old style hash (:foo => 'bar') on Ruby >= 1.9

Runtime options:
  -f, [--force]    # Overwrite files that already exist
  -p, [--pretend]  # Run but do not make any changes
  -q, [--quiet]    # Suppress status output
  -s, [--skip]     # Skip files that already exist

Rails options:
  -h, [--help]     # Show this help message and quit
  -v, [--version]  # Show Rails version number and quit

Description:
    The 'rails new' command creates a new Rails application with a default
    directory structure and configuration at the path you specify.

    You can specify extra command-line arguments to be used every time
    'rails new' runs in the .railsrc configuration file in your home directory.

    Note that the arguments specified in the .railsrc file don't affect the
    defaults values shown above in this help message.

Example:
    rails new ~/Code/Ruby/weblog

    This generates a skeletal Rails installation in ~/Code/Ruby/weblog.
    See the README in the newly created application to get going.

我哪里出错了,我该如何解决这个问题以使其成为脚手架?

【问题讨论】:

  • 不使用 Gemfile Edit 可以试试吗?
  • 不幸的是我需要 gem 文件编辑。我正在关注 Ruby on Rails 教程书(在我进入 ruby​​ on rails 开发训练营之前自学如何编码)
  • 您还在为这个问题苦苦挣扎吗?
  • 是的,遗憾的是还没有解决它。我不确定为什么它无法识别脚手架命令。我的一位同事建议尝试使用 rails generate scaffold 用户输入它并查看脚手架是否会生成,但是当我回到家时必须这样做,因为我今天没有把我的家用电脑带到办公室。

标签: ruby-on-rails scaffold


【解决方案1】:

首先你必须安装 `gem 'sqlite3' 添加到 gemfile 中

然后捆绑安装......

首先,如果您的机器上安装了 RVM,然后选择带有 rvm 的 ruby​​ 版本,然后

检查 ruby​​ 版本

ruby -v

和rails版本

rails -v

如果两者都为您提供您在应用程序中使用的版本并且捆绑完整,那么它不会提供上述选项并创建模型

【讨论】:

  • 是的,我已经安装了 RVM,我更新了包并安装了它,ruby 和 rails 以及所有 gem 文件编辑都使用我想要的版本(使用 ruby​​ -v 和 rails -v 检查,但问题仍然存在.......
  • 另外一件事是您成功地为此创建了数据库。
猜你喜欢
  • 2013-01-30
  • 1970-01-01
  • 2011-12-18
  • 2020-01-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-06-22
  • 2023-03-12
相关资源
最近更新 更多