Sha256: 2e7357a4f03f1f73ffb956c8b6356d05e0224ab86563ca9b66de9a1897f2a177
Contents?: true
Size: 1.37 KB
Versions: 3
Compression:
Stored size: 1.37 KB
Contents
class <%= @controller_name %>Controller < ApplicationController def index @<%= @resources %> = <%= @model_class %>.not_deleted end def show @<%= @resource %> = <%= @model_class.name %>.find(params[:id]) end def new @<%= @resource %> = <%= @model_class.name %>.new end def create @<%= @resource %> = <%= @model_class.name %>.new(<%= @resource %>_params) begin @<%= @resource %>.transaction do @<%= @resource %>.save! end redirect_to :action => 'show', :id => @<%= @resource %>.id rescue ActiveRecord::RecordInvalid => e render :new end end def edit @<%= @resource %> = <%= @model_class.name %>.find(params[:id]) end def update @<%= @resource %> = <%= @model_class.name %>.find(params[:id]) @<%= @resource %>.attributes = params[:<%= @resource %>_params] begin @<%= @resource %>.transaction do @<%= @resource %>.save! end redirect_to :action => 'show', :id => @<%= @resource %>.id rescue ActiveRecord::RecordInvalid => e render :edit end end def destroy @<%= @resource %> = <%= @model_class.name %>.find(params[:id]) @<%= @resource %>.transaction do @<%= @resource %>.destroy_logically! end redirect_to :action => 'index' end private def <%= @resource %>_params params.require(:<%= @resource %>).permit! end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
daddy-0.3.6 | templates/app/controllers/controller.rb.erb |
daddy-0.3.4 | templates/app/controllers/controller.rb.erb |
daddy-0.3.3 | templates/app/controllers/controller.rb.erb |