So far this appears to be working, but it looks kind of jacked up.
I'm concerned that I could be opening myself up to a hole in the
future (security or portability) by doing what I've outlined below.
Are there any better ways to go about doing this WITHOUT calling save
more than once?
Here's an example:
-------------------------------
POST data: {car => {"make" => "Pontiac", "model" => "GTO", "year" =>
"2004"}}
car_controller.rb
------------------------
def edit
@car = Car.find(:first, :conditions => {:id => params[:id]})
@car.condition = "Good"
@car.value = "$24,924" # Totally hypothetical
if @car.update_attributes(params[:car])
flash[:notice] = "Car updated successfully."
redirect_to :action => view, :id => @car.id
else
flash[:warning] = "There was a problem updating your entry."
end
end
-----------
As you can see in this example, I'm manually assigning values to an
object inherited from ActiveRecord BEFORE calling update_attributes.
What concerns me is that I'm passing in the hash from POST to
update_attributes, and while it seems to work just fine and I'm
receiving no deprecation warnings, I'm curious: is there a better way
to do this without calling save multiple times?
I have a callback after save that sends out e-mail, so that's why I
don't want multiple saves (no sense in 2-3 emails for each edit).
Thanks for your help =)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---