Sha256: d2213dbe717fe89507112f47a356c7e48478f2718f0f0632467f79df51c4dda8
Contents?: true
Size: 1.29 KB
Versions: 5
Compression:
Stored size: 1.29 KB
Contents
class <%= plural_name.camelize %>Controller < ApplicationController def index @<%= plural_name.underscore %> = <%= class_name %>.all end def show @<%= singular_name.underscore %> = <%= class_name %>.find_by_id(params[:id]) end def new @<%= singular_name.underscore %> = <%= class_name %>.new end def create @<%= singular_name.underscore %> = <%= class_name %>.new <% attributes.each do |attribute| -%> @<%= singular_name.underscore %>.<%= attribute.name %> = params[:<%= attribute.name %>] <% end %> if @<%= singular_name.underscore %>.save redirect_to "/<%= plural_name %>" else render 'new' end end def edit @<%= singular_name.underscore %> = <%= class_name %>.find_by_id(params[:id]) end def update @<%= singular_name.underscore %> = <%= class_name %>.find_by_id(params[:id]) <% attributes.each do |attribute| -%> @<%= singular_name.underscore %>.<%= attribute.name %> = params[:<%= attribute.name %>] <% end %> if @<%= singular_name.underscore %>.save redirect_to "/<%= plural_name %>" else render 'edit' end end def destroy @<%= singular_name.underscore %> = <%= class_name %>.find_by_id(params[:id]) @<%= singular_name.underscore %>.destroy redirect_to "/<%= plural_name %>" end end
Version data entries
5 entries across 5 versions & 1 rubygems