0

我在 RoR4 中构建了一个 Rails 应用程序,需要将其部署在运行版本 3.2.13 的服务器上。尝试运行 rails 服务器时出现错误。如何将我的应用程序转换为在旧版本的 Rails 中运行?

这就是我的 gemfile 的样子:

source 'https://rubygems.org'


gem 'rails', '4.0.2'
gem 'sqlite3'
#gem 'pg'
gem 'sass-rails' '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jquery-turbolinks'
gem 'jbuilder', '~> 1.2'
gem 'acts-as-taggable-on'

group :doc do

  gem 'sdoc', require: false
end

group :development, :test do
end

这是我尝试运行 rails 服务器时遇到的错误:

 dhcp-10-156-44-120:icon-library Lewis$ rails s
Usage:
  rails new APP_PATH [options]

Options:
  -r, [--ruby=PATH]              # Path to the Ruby binary of your choice
                                 # Default: /Users/yudi/.rvm/rubies/ruby-2.0.0-p353/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.
dhcp-10-156-44-120:icon-library Lewis$
4

1 回答 1

0

只是一个疯狂的猜测,但在我看来,您的问题可能是您的服务器无法识别您的rails s命令,因为您为您的应用程序运行了错误版本的 ruby​​ 和 rails。

第一步是在终端中运行:

ruby -v

假设您的 ruby​​ 版本是 1.9.3,那么上述命令的输出将是:ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-linux]

将您的 ruby​​ 版本添加到 Gemfile 的顶部:

ruby "1.9.3"

将所需的 rails 版本添加到 Gemfile:

gem 'rails', '3.2.13'

在那次运行之后bundle install

随着您的进行,您可能需要对您的 rails 应用程序进行更多更改,但这应该至少使您的服务器能够识别您的应用程序。

于 2014-08-04T09:52:06.200 回答