Sha256: c39b83d5778fa1a0c3a2bb4238edafb05dde8952c63e3d9b04b8ae361314bc8d
Contents?: true
Size: 1.71 KB
Versions: 10
Compression:
Stored size: 1.71 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 named_routes? -%> if @<%= singular_name.underscore %>.save redirect_to <%= plural_name %>_url else render 'new' end <% else -%> if @<%= singular_name.underscore %>.save redirect_to "/<%= plural_name %>" else render 'new' end <% 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 named_routes? -%> if @<%= singular_name.underscore %>.save redirect_to <%= plural_name %>_url else render 'new' end <% else -%> if @<%= singular_name.underscore %>.save redirect_to "/<%= plural_name %>" else render 'new' end <% end -%> end def destroy @<%= singular_name.underscore %> = <%= class_name %>.find_by_id(params[:id]) @<%= singular_name.underscore %>.destroy <% if named_routes? -%> redirect_to <%= plural_name %>_url <% else -%> redirect_to "/<%= plural_name %>" <% end -%> end end
Version data entries
10 entries across 10 versions & 1 rubygems