Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # in works controller i want to change the action_required attribute
- # of a related medium, depending on whether the checkbox value
- # :action_required_done (no attribute, just a check_box_tag) is set
- # params are [:work][:medium_attributes] from a nested form
- # [:medium_attributes] has something called :action_required
- def update
- @work = Work.find(params[:id])
- respond_to do |format|
- # does what i want
- if params[:action_required_done]
- @work.medium.update_attribute(:action_required, false)
- end
- # alas this resets :action_required to the submitted data
- if @work.update_attributes(params[:work])
- # how do i avoid the second update?
Add Comment
Please, Sign In to add comment