nkuht-donate/app/controllers/admin/nkuht_donate_uses_controlle...

53 lines
1.2 KiB
Ruby

class Admin::NkuhtDonateUsesController < OrbitAdminController
def initialize
super
@app_title = 'nkuht_donate'
end
def index
@nkuht_donate_uses = NkuhtDonateUse.all
@url = admin_nkuht_donate_use_path(@nkuht_donate_uses)
end
def create
@nkuht_donate_use = NkuhtDonateUse.new(nkuht_donate_use_params)
@nkuht_donate_use.save
redirect_to request.referer, :status => 303
end
def create_in_form
@nkuht_donate_use = NkuhtDonateUse.new(nkuht_donate_use_params)
@nkuht_donate_use.save
render :json => {:id=>@nkuht_donate_use.id.to_s, :title=>@nkuht_donate_use.title}.to_json ,:layout => false
end
def update
@nkuht_donate_use = NkuhtDonateUse.find(params[:id])
@nkuht_donate_use.update_attributes(nkuht_donate_use_params)
redirect_to request.referer, :status => 303
end
def toggle
@nkuht_donate_use = NkuhtDonateUse.find(params[:id])
@nkuht_donate_use.save!
redirect_to request.referer, :status => 303
end
def delete_uses
uses = NkuhtDonateUse.find(params[:ids].split(',')) rescue nil
if uses
uses.each(&:destroy)
end
redirect_to request.referer, :status => 303
end
private
def nkuht_donate_use_params
params.require(:nkuht_donate_use).permit!
end
end