简体   繁体   中英

Command Prompt for Rails application

Is there a difference in typing in 'rails generate model X' versus 'ruby generate model X'?

For me (and on windows 7), it seems like only the latter works and the former doesn't, which has been a point of confusion for me.

generate is a rails script, so it is best used using the rails command as you have seen:

rails generate model X

if you wanted to use the ruby command, you would have to tell that it is a rails script like so:

ruby script/generate model X

As said in the comments, keep in mind that this was for rails 2.3 below. If you're using rails 3, it's:

ruby script/rails generate model X

although I don't know why you would want the additional "ruby script" when typing your command. In addition, you can further shorten rails script commands to:

rails g model X
rails g migration addcolumnxtotabley

etc. You can also use c and s for console and server respectively like so:

rails c 
rails s
rails s -p 4000 (sets the port to 4000 instead of 3000)
rails s -u (if you have ruby-debug19 installed)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM