I used IDE development when I learned rails a few days ago. I didn't feel how fast the efficiency of rails is. Today, I tried it through the command line and I was shocked. without writing a line of code, I actually completed a simple model of adding, deleting, modifying, and querying.
As follows:
First, configure the environment.
Run the command: rails new blog to create an MVC project structure named "blog.
Rake DB: Create to create a database (use sqllite directly here)
Rails generate controller home index create the controller and index method named home and other struct
Configure the routes. RB route root: 'home # Index' so that the default home page path is home/index.
Then start the rails server command. Access localhost: 3000
You will find the HTML corresponding to the view/home/index.html. ERB File
Rails generate scaffold posts name: String title: String content: string create a structure (including the MVC of this model) where the model is posts Field name, title, and content)
Rake DB: Execute database migration with migrate
Open the view/home/index.html. ERB file and add a line of code <% = link_to 'to posts List page', posts_path %>
Save and exit.
You will be surprised to find that there is no code written, and a posts model with addition, deletion, modification, and query has come out.
Of course, this is just a simple model, and the actual production and development will not be so simple, but we can get some inspiration:
Convention is better than Configuration
This article is from the "Learn Java again" blog, please be sure to keep this source http://3131854.blog.51cto.com/3121854/1550975
Ruby on Rails command line