forgeplus/app/controllers/admins/graduation_standards_contro...

33 lines
932 B
Ruby
Raw Normal View History

2020-03-09 00:40:16 +08:00
class Admins::GraduationStandardsController < Admins::BaseController
def index
standards = EcGraduationStandard.all.order("updated_at desc")
@params_page = params[:page] || 1
@standards = paginate standards
end
def create_standard
ActiveRecord::Base.transaction do
if params[:graduation_id] == "-1"
content = params[:content]
EcGraduationStandard.create(:content => content)
else
graduation = EcGraduationStandard.find_by(id: params[:graduation_id])
graduation.update_attribute(:content, params[:content])
end
standards = EcGraduationStandard.all.order("updated_at desc")
@params_page = params[:page] || 1
@standards = paginate standards
end
end
def destroy
ActiveRecord::Base.transaction do
@graduation = EcGraduationStandard.find_by(id: params[:id])
@graduation.destroy
render_success_js
end
end
end