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.