Sha256: 51b913f0b5275badb20dfb3420ef40700543aa36ea2b6acfa5b3f5c6dbcc2956
Contents?: true
Size: 1.03 KB
Versions: 5
Compression:
Stored size: 1.03 KB
Contents
module Admin class <%= name.pluralize %>Controller < BaseController handle_return_path PER_PAGE = 20 def index @<%= @collection_name %> = <%= @class_name %>.ordered.paginate(page: params[:page], per_page: PER_PAGE) end def new @<%= @instance_name %> = <%= @class_name %>.new end def create @<%= @instance_name %> = <%= @class_name %>.new(params[:<%= @instance_name %>].permit!) if @<%= @instance_name %>.save redirect_or_render :edit else render :new end end def edit @<%= @instance_name %> = <%= @class_name %>.find(params[:id]) end def update @<%= @instance_name %> = <%= @class_name %>.find(params[:id]) if @<%= @instance_name %>.update_attributes(params[:<%= @instance_name %>].permit!) redirect_or_render :edit else render :edit end end def destroy @<%= @instance_name %> = <%= @class_name %>.find(params[:id]) @<%= @instance_name %>.destroy redirect_to_last end end end
Version data entries
5 entries across 5 versions & 1 rubygems