use simple_form and hash updates
This commit is contained in:
parent
cb734f9de7
commit
fba9f3d2fb
@ -36,15 +36,8 @@ module Merged
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@card.allowed_fields.each do |key|
|
@card.update(params[:card])
|
||||||
if( params.has_key?(key) )
|
@card.update_options( params[:options])
|
||||||
@card.update(key, params[key])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
options = params[:option]
|
|
||||||
@card.option_definitions.each do |option|
|
|
||||||
@card.set_option(option.name, options[option.name])
|
|
||||||
end if options
|
|
||||||
@card.edit_save(current_member.email)
|
@card.edit_save(current_member.email)
|
||||||
redirect_to section_cards_url(@card.section.id) , notice: "Updated #{@card.header}"
|
redirect_to section_cards_url(@card.section.id) , notice: "Updated #{@card.header}"
|
||||||
end
|
end
|
||||||
|
@ -66,10 +66,7 @@ module Merged
|
|||||||
|
|
||||||
def update
|
def update
|
||||||
@section.update(params[:section])
|
@section.update(params[:section])
|
||||||
options = params[:option]
|
@section.update_options( params[:options])
|
||||||
@section.option_definitions.each do |option|
|
|
||||||
@section.set_option(option.name, options[option.name])
|
|
||||||
end if options
|
|
||||||
@section.edit_save(current_member.email)
|
@section.edit_save(current_member.email)
|
||||||
redirect_to :section , notice: "Update ok"
|
redirect_to :section , notice: "Update ok"
|
||||||
end
|
end
|
||||||
|
@ -59,6 +59,7 @@ module Merged
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update(hash)
|
def update(hash)
|
||||||
|
return unless hash
|
||||||
hash.each do |key , value|
|
hash.each do |key , value|
|
||||||
raise "unsuported field #{key} for #{template}:#{allowed_fields}" unless allowed_fields.include?(key.to_sym)
|
raise "unsuported field #{key} for #{template}:#{allowed_fields}" unless allowed_fields.include?(key.to_sym)
|
||||||
if(! attributes[key].nil? ) # first setting ok, types not (yet?) specified
|
if(! attributes[key].nil? ) # first setting ok, types not (yet?) specified
|
||||||
@ -70,6 +71,12 @@ module Merged
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update_options( options )
|
||||||
|
return unless options
|
||||||
|
option_definitions.each do |option|
|
||||||
|
set_option(option.name, options[option.name])
|
||||||
|
end
|
||||||
|
end
|
||||||
#other may be nil
|
#other may be nil
|
||||||
def swap_index_with(other)
|
def swap_index_with(other)
|
||||||
return unless other
|
return unless other
|
||||||
|
Loading…
Reference in New Issue
Block a user