Project

General

Profile

Feature #6641 » do_not_allow_setting_is_default_if_project_id_is_set.patch

fix to backend so users can't submit an invalid enumeration - Albert Rosenfield, 2010-10-25 17:06

View differences:

app/controllers/enumerations_controller.rb 2010-10-19 15:25:39.202264228 +0200 → app/controllers/enumerations_controller.rb 2010-10-19 15:25:34.182267531 +0200
end
def create
if params[:enumeration][:project_id].length != 0
# disallow is_default if project-specific
params[:enumeration][:is_default] = 0
end
@enumeration = Enumeration.new(params[:enumeration])
@enumeration.type = params[:enumeration][:type]
if @enumeration.save
......
end
def update
if params[:enumeration][:project_id].length != 0
# disallow is_default if project-specific
params[:enumeration][:is_default] = 0
end
@enumeration = Enumeration.find(params[:id])
@enumeration.type = params[:enumeration][:type] if params[:enumeration][:type]
if @enumeration.update_attributes(params[:enumeration])
(1-1/2)