[英]Rails Migration doesn't create anything
I'm currently on section 8.2.1 of Michael Hartl's rails tutorial. 我目前正在Michael Hartl的rails教程的8.2.1节中。 I'm currently trying to add a remember_token to my Users model to keep track of sessions.
我目前正在尝试向我的用户模型添加一个Remember_token来跟踪会话。
When I run 'rails generate migration add_remember_token_to_users', the database does not get updated and no files are created in db/migrate 当我运行“ rails generate migration add_remember_token_to_users”时,数据库未更新,并且在db / migrate中未创建文件
This is what I get when I run 'rails generate migration add_remember_token_to_users' 这就是我在运行“ 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.
edit: result from running '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
By the looks of the error your getting, your not actually in a rails project directory 从错误的外观来看,您实际上不在Rails项目目录中
Try running the same rails generate command when you are at the root of your rails project 当您位于Rails项目的根目录时,请尝试运行相同的rails generate命令
EDIT 编辑
Try adding a folder called 尝试添加一个名为
script
脚本
to your rails root as Vasseurth linked to Vasseurth链接到您的rails根
in this folder add a file called 在此文件夹中添加一个名为
rails
栏杆
and add to it 并添加到它
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands'
It turns out that I misplaced my bin folder. 原来我放错了bin文件夹。 It was contained within my 'app' folder.
它包含在我的“ app”文件夹中。 I cut/pasted my bin folder back into the app's root directory, and now the migration works fine.
我将bin文件夹剪切/粘贴回应用程序的根目录,现在迁移正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.