Sha256: bfbc9b4fb0750a213ff08100f52a87ea67ac2bc25d5cd460eb5fb81cc37c513f
Contents?: true
Size: 1.25 KB
Versions: 2
Compression:
Stored size: 1.25 KB
Contents
<% klass = class_name.singularize -%> <% ivar = class_name.snake_case.singularize -%> class <%= class_name %> < Application provides :xml, :js, :yaml def index @<%= ivar.pluralize %> = <%= klass %>.all render @<%= ivar.pluralize %> end def show(id) @<%= ivar %> = <%= klass %>[id] raise NotFound unless @<%= ivar %> render @<%= ivar %> end def new only_provides :html @<%= ivar %> = <%= klass %>.new render @<%= ivar %> end def create(<%= ivar %>) @<%= ivar %> = <%= klass %>.new(<%= ivar %>) if @<%= ivar %>.save redirect url(:<%= ivar %>, @<%= ivar %>) else render :action => :new end end def edit(id) only_provides :html @<%= ivar %> = <%= klass %>[id] raise NotFound unless @<%= ivar %> render end def update(id, <%= ivar %>) @<%= ivar %> = <%= klass %>[id] raise NotFound unless @<%= ivar %> if @<%= ivar %>.update_attributes(<%= ivar %>) redirect url(:<%= ivar %>, @<%= ivar %>) else raise BadRequest end end def destroy(id) @<%= ivar %> = <%= klass %>[id] raise NotFound unless @<%= ivar %> if @<%= ivar %>.destroy! redirect url(:<%= ivar.pluralize %>) else raise BadRequest end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
merb_datamapper-0.4.4 | datamapper_generators/resource_controller/templates/controller.rb |
merb_datamapper-0.5 | datamapper_generators/resource_controller/templates/controller.rb |