Rails RESTful helper

GET
<%= link_to(“List", posts_path) %> #index
<%= link_to(“Show", post_path(@post)) %> #show
<%= link_to(“New", new_post_path) %> #new
<%= link_to(“Edit", edit_post_path(@post)) %> #edit

POST
<%= form_for @post , :url => posts_path , :html => {:method => :post} do |f| %> #create

PUT
<%= form_for @post , :url => post_path(@post) , :html => {:method => :put} do |f| %> #update

Delete
<%= link_to(“Destroy", post_path(@post), :method => :delete ) #destroy

廣告