8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/configurable_engine/configurables_controller_methods.rb', line 8
def update
failures = Configurable
.keys.map do |key|
Configurable.find_by_name(key) ||
Configurable.create {|c| c.name = key}
end.reject do |configurable|
configurable.value = params[configurable.name]
configurable.save
end
if failures.empty?
redirect_to(action: :show, :notice => "Changes successfully updated")
else
flash[:error] = failures.flat_map(&:errors).flat_map(&:full_messages).join(',')
redirect_to(action: :show)
end
end
|