Sha256: d6014aced44565db2590e00def990083874368a05ebf5ae8b7556dd2393874ea
Contents?: true
Size: 1.54 KB
Versions: 6
Compression:
Stored size: 1.54 KB
Contents
#coding: utf-8 class Admin::<%= @model_name.demodulize.pluralize -%>Controller < Admin::ApplicationController <%- if column_names.include?("visible") -%> def toggleshow @<%= resource_name %> = <%= @model_name.demodulize -%>.find(params[:id]) @<%= resource_name %>.toggle(:visible) @<%= resource_name %>.save render :nothing => true end <%- end -%><%- if column_names.include?("position") -%> def sort params[:<%= resource_name %>].each_with_index do |id, idx| @<%= resource_name %> = <%= @model_name.demodulize -%>.find(id) @<%= resource_name %>.position = idx @<%= resource_name %>.save end render :nothing => true end <%- end -%> def edit @<%= resource_name %> = <%= @model_name.demodulize -%>.find(params[:id]) end def create @<%= parent_name %> = <%= parent_name.capitalize -%>.find(params[:<%= parent_name %>_id]) @<%= resource_name %> = @<%= parent_name %>.<%= plural_resource_name %>.create(params[:<%= resource_name %>]) end def update @<%= resource_name %> = <%= @model_name.demodulize -%>.find(params[:id]) if @<%= resource_name %>.update_attributes(params[:<%= resource_name %>]) redirect_to [:edit, :admin, @<%= resource_name %>.<%= parent_name %>], :notice => "#{<%= @model_name.demodulize %>.model_name.human} #{t 'flash.notice.was_updated'}" else render 'edit' end end def destroy @<%= resource_name %> = <%= @model_name.demodulize -%>.find(params[:id]) @<%= resource_name %>.destroy end end
Version data entries
6 entries across 6 versions & 1 rubygems