14

我是 ruby​​ 和 rails 的新手,我在 ubuntu 中安装了 rails。但是当我通过键入“rails s”进入启动服务器时,它不会启动并出现以下消息。但我可以通过命令 rails new new_project 创建一个新项目。请rails专家帮帮我。

root@ubuntu:~# rails s Usage: rails new APP_PATH [options] Options: -j, [--javascript=JAVASCRIPT] 
# Preconfigure for selected JavaScript library # Default: jquery -m, [--template=TEMPLATE] # Path to an application template (can be a filesystem path or URL) [--dev] 
# Setup the application with Gemfile pointing to your Rails checkout -J, [--skip-javascript] # Skip JavaScript files [--edge] 
# Setup the application with Gemfile pointing to Rails repository -G, [--skip-git] 
# Skip Git ignores and keeps -d, [--database=DATABASE] 
# Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/frontbase/ibm_db/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc) 
# Default: sqlite3 -b, [--builder=BUILDER] 
# Path to a application builder (can be a filesystem path or URL) -r, [--ruby=PATH] 
# Path to the Ruby binary of your choice 
# Default: /usr/bin/ruby1.8 [--old-style-hash] 
# Force using old style hash (:foo => 'bar') on Ruby >= 1.9 [--skip-gemfile] 
# Don't create a Gemfile -O, [--skip-active-record] 
# Skip Active Record files [--skip-bundle] # Don't run bundle install -T, [--skip-test-unit] 
# Skip Test::Unit files -S, [--skip-sprockets] 
# Skip Sprockets files Runtime options: -q, [--quiet] 
# Supress status output -f, [--force] 
# Overwrite files that already exist -s, [--skip] 
# Skip files that already exist -p, [--pretend] 
# Run but do not make any changes 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
4

6 回答 6

34

更好的方法是使用以下命令更新您的 bin

bundle exec rake rails:update:bin
于 2014-04-15T17:21:43.853 回答
11
  1. 您需要创建一个新的 Rails 应用程序(除非您已经有一个)

    rails new my_app
    
  2. 转到您的应用程序目录

    cd my_app
    
  3. 在该目录中启动服务器

    rails s
    
于 2012-04-07T12:25:04.613 回答
5

一旦你创建了项目并cd'd 进入它:

script/server如果您使用的是 rails 版本 2.x,请使用

script/rails server如果您使用的是 rails 版本 3.x,请使用

bin/rails server如果您使用的是 rails 版本 4.x,请使用

于 2012-04-07T12:24:23.047 回答
1

在启动 rails 服务器之前,您必须 cd 进入应用程序的目录。那是因为服务器需要知道它应该服务的应用程序。

于 2013-01-27T21:05:02.463 回答
1

我遇到了这个问题并且困惑了一分钟,直到我意识到我不小心删除了我的 bin 文件夹。

如何修复它:

  1. 备份您的应用程序。
  2. cd退出 Rails 应用程序的根目录。
  3. 运行rails new name_of_your_app——确保它与已经存在的目录同名。
  4. Rails 将再次构建该文件夹,询问您是否要覆盖文件,n每次询问时点击“否”。
  5. Rails 将添加丢失的 bin 文件,而如果您点击n其他所有内容,它将保留其他所有内容。
  6. 在我的情况下,我将 HAML 与application.html.haml文件一起使用,因此 Rails 还application.html.erb为我生成了一个views/layouts我不需要的文件,因此将其删除。注意生成的任何其他文件并删除您不想要的任何文件。
  7. 运行rails s以启动 WEBrick 服务器。
于 2017-08-20T19:21:29.810 回答
1

我也是 Ruby on rails 的新手。当我的电脑意外关机时,我发现了同样的问题。我通过以下步骤修复它。

  1. 创建一个新的应用程序。Rails 新演示 --Database=postgresql

  2. 复制新 Demo 应用的 Bin 文件夹。

  3. 删除旧应用程序的 Bin 文件夹(显示错误)

  4. 将 Demo App 中的 New bin 文件夹粘贴到旧 App。

  5. 启动服务器 Rails 服务器

请注意,您可以从 Github 复制 bin 文件夹。https://github.com/hoovercj/depot

于 2019-05-22T12:52:35.393 回答