簡體   English   中英

Rails遷移不會創建任何東西

[英]Rails Migration doesn't create anything

我目前正在Michael Hartl的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.

編輯:運行“目錄”的結果

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

從錯誤的外觀來看,您實際上不在Rails項目目錄中

當您位於Rails項目的根目錄時,請嘗試運行相同的rails generate命令

編輯

嘗試添加一個名為

腳本

Vasseurth鏈接到您的rails根

在此文件夾中添加一個名為

欄桿

並添加到它

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

如果您實際上是在Rails項目目錄中,請查看問題。 它與您的目錄幾乎完全相同,可以在目錄內仍然收到此錯誤。

原來我放錯了bin文件夾。 它包含在我的“ app”文件夾中。 我將bin文件夾剪切/粘貼回應用程序的根目錄,現在遷移正常。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM