A concise summary of common Rails command lines

Source: Internet
Author: User

New Class
Copy codeThe Code is as follows: ruby script/generate Model <Class Name> <Field 1 >:< type>...
Ruby script/generate Model Item name: string age: integer
Remove Class
Copy codeThe Code is as follows: ruby script/destroy Model

New Controller
Copy codeThe Code is as follows: ruby script/generate Controller <Controller Name> <Action 1> <Action 2>...
Ruby script/generate Controller Web index remove news ....

Add Field
Copy codeThe Code is as follows: ruby script/generate Migration Add <Migration File ID> To <Class Name> <Field 1 >:< type>...
Ruby script/generate Migration AddLanguagesToLive english_name: string japanese_name: string

Remove Field
Copy codeThe Code is as follows: ruby script/generate Migration Remove <Migration File ID> From <Class Name> <Field 1 >:< type>...
Ruby script/generate Migration RemoveLanguagesFromLive english_name: string japanese_name: string

Application database migration File(Make the database structure modification take effect)
Copy codeThe Code is as follows: rake db: migrate
Rake db: migrate RAILS_ENV = production
Roll back the last modification
Copy codeThe Code is as follows: rake db: rollback

Clear logs
Copy codeThe Code is as follows: rake log: clear
View logs
Copy codeThe Code is as follows: type log \ production. log

Create a project
Copy codeThe Code is as follows: Rails project name
Rails demo

Start ruby Service
Copy codeThe Code is as follows: ruby script/server

Database Operations
Copy codeThe Code is as follows: ruby script/console

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.