Rails迁移不会创建任何东西

时间:2014-08-05 23:39:56

标签: ruby-on-rails

我目前正在迈克尔哈特尔的导轨教程8.2.1节中。我目前正在尝试将remember_token添加到我的用户模型中以跟踪会话。

当我运行'rails generate migration add_remember_token_to_users'时,数据库没有更新,并且没有在db / migrate中创建文件

这是我运行'rails generate migration add_remember_token_to_users'时得到的

C:\Sites\sample_app>rails generate migration add_remember_token_to_users
DL is deprecated, please use Fiddle
Usage:
  rails new APP_PATH [options]

Options:
  -r, [--ruby=PATH]                                      # Path to the Ruby bina
ry of your choice
                                                         # Default: C:/RailsInst
aller/Ruby2.0.0/bin/ruby.exe
  -m, [--template=TEMPLATE]                              # Path to some applicat
ion template (can be a filesystem path or URL)
      [--skip-gemfile], [--no-skip-gemfile]              # Don't create a Gemfil
e
  -B, [--skip-bundle], [--no-skip-bundle]                # Don't run bundle inst
all
  -G, [--skip-git], [--no-skip-git]                      # Skip .gitignore file
      [--skip-keeps], [--no-skip-keeps]                  # Skip source control .
keep files
  -O, [--skip-active-record], [--no-skip-active-record]  # Skip Active Record fi
les
  -S, [--skip-sprockets], [--no-skip-sprockets]          # Skip Sprockets files
  -d, [--database=DATABASE]                              # Preconfigure for sele
cted database (options: mysql/oracle/postgresql/sqlite3/frontbase/ibm_db/sqlserv
er/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc)
                                                         # Default: sqlite3
  -j, [--javascript=JAVASCRIPT]                          # Preconfigure for sele
cted JavaScript library
                                                         # Default: jquery
  -J, [--skip-javascript], [--no-skip-javascript]        # Skip JavaScript files

      [--dev], [--no-dev]                                # Setup the application
 with Gemfile pointing to your Rails checkout
      [--edge], [--no-edge]                              # Setup the application
 with Gemfile pointing to Rails repository
  -T, [--skip-test-unit], [--no-skip-test-unit]          # Skip Test::Unit files

      [--rc=RC]                                          # Path to file containi
ng extra configuration options for rails command
      [--no-rc], [--no-no-rc]                            # Skip loading of extra
 configuration options from .railsrc file

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

Rails options:
  -h, [--help], [--no-help]        # Show this help message and quit
  -v, [--version], [--no-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.

编辑:运行'dir'

的结果
C:\Sites\sample_app>dir
 Volume in drive C is Windows8_OS
 Volume Serial Number is 02F6-CD19

 Directory of C:\Sites\sample_app

08/04/2014  11:15 PM    <DIR>          .
08/04/2014  11:15 PM    <DIR>          ..
08/04/2014  07:49 PM                 0 -e
07/06/2014  07:23 PM    <DIR>          .bundle
07/06/2014  07:19 PM               466 .gitignore
07/06/2014  07:32 PM                 8 .rspec
07/06/2014  07:32 PM               128 .secret
08/04/2014  11:15 PM    <DIR>          app
08/03/2014  07:50 PM    <DIR>          config
07/06/2014  07:19 PM               154 config.ru
08/04/2014  08:25 PM    <DIR>          db
07/06/2014  07:21 PM             1,287 Gemfile
07/06/2014  07:23 PM             5,085 Gemfile.lock
07/06/2014  07:19 PM             1,171 Gemfile~
07/06/2014  07:19 PM    <DIR>          lib
07/06/2014  08:03 PM    <DIR>          log
07/06/2014  07:19 PM    <DIR>          public
07/06/2014  07:19 PM               254 Rakefile
07/06/2014  07:33 PM               185 README.md
07/06/2014  07:19 PM               478 README.rdoc~
08/02/2014  05:03 PM    <DIR>          spec
07/06/2014  07:59 PM    <DIR>          tmp
07/06/2014  07:19 PM    <DIR>          vendor
              11 File(s)          9,216 bytes
              12 Dir(s)  883,421,155,328 bytes free

3 个答案:

答案 0 :(得分:0)

通过你得到的错误的外观,你实际上并不在rails项目目录中

当您位于rails项目的根目录时,尝试运行相同的rails generate命令

修改

尝试添加名为

的文件夹
  

脚本

当Vasseurth链接到

时,

到你的rails根目录

在此文件夹中添加名为

的文件
  

并添加

APP_PATH = File.expand_path('../../config/application',  __FILE__)
require File.expand_path('../../config/boot',  __FILE__)
require 'rails/commands'

答案 1 :(得分:0)

如果您在rails项目目录中,请查看this问题。它与你的几乎完全一样,有一个解决方案,可以进入目录并仍然收到此错误。

答案 2 :(得分:0)

事实证明我错放了我的bin文件夹。它包含在我的“app”文件夹中。我将bin文件夹剪切/粘贴回应用程序的根目录,现在迁移工作正常。