test for nccu

This commit is contained in:
Harry Bomrah 2015-09-24 15:23:49 +08:00
parent 893c4686cb
commit f2d460101f
2 changed files with 6 additions and 14 deletions

View File

@ -40,10 +40,6 @@ class Admin::NewsAdminsController < OrbitAdminController
redirect_to admin_news_admins_path redirect_to admin_news_admins_path
end end
def unit_params
params.require(:unit).permit!
end
def get_departments def get_departments
unit = Unit.find(Sanitize.clean(params[:unit])) unit = Unit.find(Sanitize.clean(params[:unit]))
departments = unit.departments.collect do |d| departments = unit.departments.collect do |d|
@ -55,4 +51,10 @@ class Admin::NewsAdminsController < OrbitAdminController
render :json => {"departments" => departments}.to_json render :json => {"departments" => departments}.to_json
end end
private
def unit_params
params.require(:unit).permit!
end
end end

View File

@ -11,14 +11,4 @@ class Unit
accepts_nested_attributes_for :departments, :allow_destroy => true accepts_nested_attributes_for :departments, :allow_destroy => true
# after_save :save_departments
def save_departments
self.departments.each do |t|
if t.should_destroy
t.destroy
end
end
end
end end