donate/app/controllers/admin/nkuht_donate_units_controll...

53 lines
1.3 KiB
Ruby

class Admin::NkuhtDonateUnitsController < OrbitAdminController
def initialize
super
@app_title = 'nkuht_donate'
end
def index
@nkuht_donate_units = NkuhtDonateUnit.all
@url = admin_nkuht_donate_unit_path(@nkuht_donate_units)
end
def create
@nkuht_donate_unit = NkuhtDonateUnit.new(nkuht_donate_unit_params)
@nkuht_donate_unit.save
redirect_to request.referer, :status => 303
end
def create_in_form
@nkuht_donate_unit = NkuhtDonateUnit.new(nkuht_donate_unit_params)
@nkuht_donate_unit.save
render :json => {:id=>@nkuht_donate_unit.id.to_s, :title=>@nkuht_donate_unit.title}.to_json ,:layout => false
end
def update
@nkuht_donate_unit = NkuhtDonateUnit.find(params[:id])
@nkuht_donate_unit.update_attributes(nkuht_donate_unit_params)
redirect_to request.referer, :status => 303
end
def toggle
@nkuht_donate_unit = NkuhtDonateUnit.find(params[:id])
@nkuht_donate_unit.save!
redirect_to request.referer, :status => 303
end
def delete_units
units = NkuhtDonateUnit.find(params[:ids].split(',')) rescue nil
if units
units.each(&:destroy)
end
redirect_to request.referer, :status => 303
end
private
def nkuht_donate_unit_params
params.require(:nkuht_donate_unit).permit!
end
end