Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def update
- respond_to do |format|
- emitter_params = params[@emitter_name.to_sym].inject({}) do |memo, tuple|
- param_key, param_value = tuple # param_key = :fuel_efficiency_in_miles_per_gallon ; param_value = "10,000"
- memo.merge({param_key => param_key.sanitize_if_numeric})
- end
- if @emitter.update_attributes(emitter_params)
- format.html do
- flash[:notice] = "#{@emitter.name} was successfully updated."
- redirect_to(@emitter)
- end
- format.xml { head :ok }
- format.js { render :template => 'emitters/update' }
- else
- format.html do
- if @characteristic
- render :template => "characteristics/edit"
- else
- render :text => "there was an error updating the #{@emitter_name.humanize.downcase} object as a whole, but there is no general edit page right now"
- end
- end
- format.xml { render :xml => @emitter.errors, :status => :unprocessable_entity }
- format.js do # currently only used for renaming
- @emitter.name = @emitter.name_was if @emitter.name_changed? # this is kind of brittle
- render :template => 'emitters/update'
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment