Sha256: 2f6f7717ffe31a0c7efd2b5bd19aaef317362e405739cbdf2d60b003cb5b68f8
Contents?: true
Size: 1.58 KB
Versions: 2
Compression:
Stored size: 1.58 KB
Contents
class <%= controller_class_name %> < ApplicationController <% if action? :index -%> # GET /<%= plural_name %> def index @<%= plural_name %> = <%= class_name %>.all end <% end -%> <% if action? :show -%> # GET /<%= plural_name %>/:id def show @<%= singular_name %> = <%= class_name %>.find(params[:id]) end <% end -%> <% if action? :new -%> # GET /<%= plural_name %>/new def new @<%= singular_name %> = <%= class_name %>.new end <% end -%> <% if action? :edit -%> # GET /<%= plural_name %>/:id/edit def edit @<%= singular_name %> = <%= class_name %>.find(params[:id]) end <% end -%> <% if action? :create -%> # POST /<%= plural_name %> def create @<%= singular_name %> = <%= class_name %>.new(params[:<%= singular_name %>]) @<%= singular_name %>.save! flash[:notice] = t('<%= i18n_prefix %>.create.success') redirect_to <%= url %> rescue ActiveRecord::RecordInvalid render 'new' end <% end -%> <% if action? :update -%> # PUT /<%= plural_name %>/:id def update @<%= singular_name %> = <%= class_name %>.find(params[:id]) @<%= singular_name %>.update_attributes!(params[:<%= singular_name %>]) flash[:notice] = t('<%= i18n_prefix %>.update.success') redirect_to <%= url %> rescue ActiveRecord::RecordInvalid render 'edit' end <% end -%> <% if action? :destroy -%> # DELETE /<%= plural_name %>/:id def destroy @<%= singular_name %> = <%= class_name %>.find(params[:id]) @<%= singular_name %>.destroy flash[:notice] = t('<%= i18n_prefix %>.destroy.success') redirect_to <%= url %> end <% end -%> end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
jzajpt-blueberry_scaffold-0.1.0 | generators/blueberry_scaffold/templates/controller.rb |
jzajpt-blueberry_scaffold-0.1.1 | generators/blueberry_scaffold/templates/controller.rb |