Sha256: 47f8147da1aeb663af6776794be23ce53418437b92d3bc548c807c93e6a3056a
Contents?: true
Size: 1.57 KB
Versions: 2
Compression:
Stored size: 1.57 KB
Contents
class <%= @controller_name.capitalize %>Controller < RIPController # HTTP GET get "/?" do @<%= @controller_name.downcase %>s = <%= @controller_name.capitalize %>.all #to_xml(<%= @controller_name.downcase %>s) to_html(:index) end get "/new" do @<%= @controller_name.downcase %> = <%= @controller_name.capitalize %>.new #to_xml(<%= @controller_name.downcase %>) to_html(:new) end get "/:id" do @<%= @controller_name.downcase %> = <%= @controller_name.capitalize %>.get(params[:id]) #to_xml(<%= @controller_name.downcase %>) to_html(:show) end get "/:id/edit" do @<%= @controller_name.downcase %> = <%= @controller_name.capitalize %>.get(params[:id]) #to_xml(<%= @controller_name.downcase %>) to_html(:edit) end # HTTP POST post "/?" do @<%= @controller_name.downcase %> = <%= @controller_name.capitalize %>.new @<%= @controller_name.downcase %>.attributes = params[:<%= @controller_name.downcase %>] @<%= @controller_name.downcase %>.save #to_xml(<%= @controller_name.downcase %>) to_html(:show) end # HTTP PUT put "/:id" do @<%= @controller_name.downcase %> = <%= @controller_name.capitalize %>.get(params[:id]) @<%= @controller_name.downcase %>.update(params[:<%= @controller_name.downcase %>]) #to_xml(<%= @controller_name.downcase %>) to_html(:show) end # HTTP DELETE delete "/:id" do @<%= @controller_name.downcase %> = <%= @controller_name.capitalize %>.get(params[:id]) @<%= @controller_name.downcase %>.destroy! #to_xml(<%= @controller_name.downcase %>) to_html(:index) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rest_in_peace-0.1.1 | lib/rest_in_peace/templates/controller.rb.erb |
rest_in_peace-0.1.0 | lib/rest_in_peace/templates/controller.rb.erb |