Ruby on Rails development from scratch (Windows) (14)-Delivery processing

Source: Internet
Author: User
Tags ruby on rails

In the last content, we completed the preparation of the order. This time we simulate a simple delivery page for the shopping cart's administrator.

1. First, we modify the order table to add a field to him Shipped_at:

CREATE TABLE orders (
ID int not NULL auto_increment,
name varchar (MB) NOT NULL,
email varchar (255) NOT NULL, Address
text is not NULL,
Pay_type char (a) not NULL,
shipped_at datetime null,
primary key (ID)
);

2. Add an action to add a method to the Admin_controller.rb file:

def ship
@pending_orders = order.pending_shipping
End

3. To the Order model implementation Pending_shipping method:

def self.pending_shipping Find
(: All,: Conditions => "shipped_at are null")
end

4. Or the old road, M has, C has, but also a V, now to fill up:

In the views of the Admin directory, create a ship.rhtml file, which reads as follows:

 

Note the Blue Line, parameter partial indicates a local template, the collection parameter specifies the set of data used, and here is the order taken out by the Pending_orders method. If I do not understand (in fact, I do not understand the J), first do not worry, wait and see the effect of the picture is good.

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.