Ruby on Rails Tutorial Chapter II User Resources &mvc&rest

Source: Internet
Author: User
Tags representational state transfer ruby on rails

Description: User resources include user data models and Web pages related to this model.

1. The user data model is as follows:

2. Using rails built-in scaffolding to generate user resources, execute the following command:

$ rails Generate scaffold User name:string email:string #创建模型

$ rails Destroy Scaffold User #销毁模型

$ bundle EXEC Rake db:migrate #用Rake来迁移数据库, in order to use the rake version specified in Gemfile, execute rake through bundle exec

Description

$./configure && make && sudo to install commands for compiling code #Unix (including Linux and Mac OS X). Rake is a ruby version of Make, a class make program written in the Ruby language. Rails has a flexible use of rake, providing many of the management tasks needed to develop database-based Web applications. Rake db:migrate may be the most commonly used. In addition to many other commands, RAKE-T db can view all database-related tasks. Rake-t View all rake tasks.

The corresponding relationship between the page and the URL in the user resource is as follows:

3. The MVC architecture in Rails is as follows:

The steps in the diagram are described below:

4. Rest Framework Description

Rest is the abbreviation for representational state transfer, which means "presentation-level transformation", which is proposed by computer scientist Roy Fielding. Rest is an architectural approach for developing distributed, network-based systems and software programs, such as WWW and Web applications. In rails, rest means that most components, such as users and microblogs, are modeled, turned into resources (resource), can create (create), read, update, and delete (delete), These actions correspond to CRUD operations and HTTP request methods (Post,get,patch and delete) in the relational database. The user model conforms to the rest framework's routing as follows:

5, the shortage of this user resources

Scaffolding generates user resources with the following disadvantages:

Ruby on Rails Tutorial Chapter II User Resources &mvc&rest

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.