Sha256: 7ffec184a91a1391d2ac724dd86106098d492b19025721ec48a71ee071ab36c5
Contents?: true
Size: 1.04 KB
Versions: 5
Compression:
Stored size: 1.04 KB
Contents
module Admin class <%= name.camelize.pluralize %>Controller < BaseController PER_PAGE = 20 def index @<%= @collection_name %> = <%= @class_name %>.order(created_at: :desc).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