Sha256: 141ba1b751229be99e086b1e71ecdd5b9bd84f5e98e4c099c5eaca7c1e805e32
Contents?: true
Size: 1.63 KB
Versions: 1
Compression:
Stored size: 1.63 KB
Contents
class <%= class_name %> < Application # provides :xml, :yaml, :js def index @<%= plural_model %> = <%= model_class_name %>.find(:all) display @<%= plural_model %> end def show @<%= singular_model %> = <%= model_class_name %>.find_by_id(params[:id]) raise NotFound unless @<%= singular_model %> display @<%= singular_model %> end def new only_provides :html @<%= singular_model %> = <%= model_class_name %>.new(params[:<%= singular_model %>]) render end def create @<%= singular_model %> = <%= model_class_name %>.new(params[:<%= singular_model %>]) if @<%= singular_model %>.save redirect url(:<%= (modules.collect{|m| m.downcase} << singular_model).join("_") %>, @<%= singular_model %>) else render :new end end def edit only_provides :html @<%= singular_model %> = <%= model_class_name %>.find_by_id(params[:id]) raise NotFound unless @<%= singular_model %> render end def update @<%= singular_model %> = <%= model_class_name %>.find_by_id(params[:id]) raise NotFound unless @<%= singular_model %> if @<%= singular_model %>.update_attributes(params[:<%= singular_model %>]) redirect url(:<%= (modules.collect{|m| m.downcase} << singular_model).join("_") %>, @<%= singular_model %>) else raise BadRequest end end def destroy @<%= singular_model %> = <%= model_class_name %>.find_by_id(params[:id]) raise NotFound unless @<%= singular_model %> if @<%= singular_model %>.destroy redirect url(:<%= (modules.collect{|m| m.downcase} << singular_model).join("_") %>s) else raise BadRequest end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
merb_activerecord-0.9.4 | lib/generators/templates/resource_controller/app/controllers/%file_name%.rb |