Sha256: 90429555b1078e3994dfa0d554d3155ee5a06dfadb4729e2adf5bd1f7a0e6635
Contents?: true
Size: 1.17 KB
Versions: 1
Compression:
Stored size: 1.17 KB
Contents
module Panel class <%= plural_name.camelize %>Controller < BaseController def index <%= @instance_plural %> = <%= class_name %>.search(params[:q]).page(params[:p].present? ? params[:p].to_i : 1).per(15) end def new <%= @instance_singular %> = <%= class_name %>.new end def create <%= @instance_singular %> = <%= class_name %>.new(<%= @params_method %>) if <%= @instance_singular %>.save redirect_to <%= @index_path %>, notice: t('flash.notice.create') else render :new end end def edit <%= @instance_singular %> = <%= class_name %>.find(params[:id]) end def update <%= @instance_singular %> = <%= class_name %>.find(params[:id]) if <%= @instance_singular %>.update_attributes(<%= @params_method %>) redirect_to <%= @index_path %>, notice: t('flash.notice.update') else render :edit end end def destroy <%= class_name %>.destroy params[:id] redirect_to <%= @index_path %>, notice: t('flash.notice.destroy') end protected def <%= @params_method %> params.require(<%= @param_singular %>).permit() end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
panel-0.1.5 | lib/generators/panel/templates/resource/resource_controller.rb |