typing 'rails console' doesn't start?

前端 未结 9 1265
花落未央
花落未央 2020-12-05 22:57

I typed this:

>rails console

and got this:

Usage:
  rails new APP_PATH [options]

Options:
      [--skip-gemfile]                


        
相关标签:
9条回答
  • 2020-12-05 23:28

    I just ran into this same problem while upgrading a Rails 2 app to Rails 3. When running rails console (or really rails [anything]) in my app's root directory, I would see general rails new usage output (as Blankman referenced in the original question).

    The problem was that I had not removed the old Rails 2 scripts from the script directory. After removing everything in the script directory and adding the script/rails file that is auto-generated in each new Rails 3 app, the rails command now works as expected.

    In order to get the latest contents of the script/rails file, generate a new app and copy the file into your Rails 2 app that you're upgrading. As of Rails 3.0.7, here's what's in this file:

    #!/usr/bin/env ruby
    # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
    
    APP_PATH = File.expand_path('../../config/application',  __FILE__)
    require File.expand_path('../../config/boot',  __FILE__)
    require 'rails/commands'
    
    0 讨论(0)
  • 2020-12-05 23:33

    I had this problem when I upgraded Rails 2 to 3 and was able to fix it by doing what Nick said, then also running bundle exec rails console production.

    0 讨论(0)
  • 2020-12-05 23:35

    You need to into the project directory and command rails console eg:

    D:\workspace\>rails blog
    D:\workspace\>cd blog
    D:\workspace\blog\> rails c
    loading en...
    
    0 讨论(0)
  • 2020-12-05 23:35

    In my case bin/rails c worked off my app root folder

    0 讨论(0)
  • 2020-12-05 23:39

    are you in a rails 3 app directory?

    do you have multiple versions of rails installed?

    try checking 'which rails', and make sure this is a rails 3 executable you are running - that usage looks like rails 2.x.

    0 讨论(0)
  • 2020-12-05 23:43

    In Rails 2.3.x the command is script/console within a given Rails application directory to start a Ruby console with the default Rails environment loaded into memory. Not sure if Rails 3.0 is the same or not.

    0 讨论(0)
提交回复
热议问题