48 lines
1.2 KiB
Ruby
48 lines
1.2 KiB
Ruby
class Admin::ResearchCategoriesController < OrbitMemberController
|
|
|
|
def new
|
|
@research_category = ResearchCategory.new
|
|
@url = admin_research_categories_path
|
|
end
|
|
|
|
def create
|
|
ResearchCategory.create(r_c_params)
|
|
@research_categories = ResearchCategory.all.asc(:sort_postion)
|
|
end
|
|
|
|
def edit
|
|
@research_category = ResearchCategory.find(params[:id]) rescue nil
|
|
@url = admin_research_category_path(@research_category)
|
|
end
|
|
|
|
def update
|
|
research_category = ResearchCategory.find(params[:id]) rescue nil
|
|
if !research_category.nil?
|
|
research_category.update_attributes(r_c_params)
|
|
research_category.save
|
|
end
|
|
@research_categories = ResearchCategory.all.asc(:sort_postion)
|
|
end
|
|
|
|
def destroy
|
|
research_category = ResearchCategory.find(params[:id]) rescue nil
|
|
research_category.destroy if !research_category.nil?
|
|
@research_categories = ResearchCategory.all.asc(:sort_postion)
|
|
end
|
|
|
|
def update_order
|
|
orders = params["order"]
|
|
ResearchCategory.each do |rc|
|
|
rc.sort_position = orders["#{rc.id}"]
|
|
rc.save
|
|
end
|
|
render :json => {"success" => true}.to_json
|
|
end
|
|
|
|
private
|
|
|
|
def r_c_params
|
|
params.require(:research_category).permit!
|
|
end
|
|
|
|
end |