[英]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.