You don't need to integrated it at the update_attributes method,
here's an example:

class User

  def activate( save = true )
    ##do activate stuff and save the model if save == true
  end

  def activated=( new_value )
    selc.ativate(true) if new_value == true and
self.read_attribute(:ativated) == false
  end

end

You would just pass the activated attribute value and "activate" or
deactivate the user as required and without writting a new action.

But if something like this doesn't work for your model, i guess you're
out of luck.

-
Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en)



On Fri, Jan 23, 2009 at 5:29 PM, Simone Guerra
<[email protected]> wrote:
>
> Hi Maurício, thanks for your reply.
> In fact I can't just reuse another action because it's not just a matter
> of changing a field in the database (which in that case update could be
> ok), I also perform some background operations like sending emails and
> updating other protected fields of the model (like date of activation or
> removing activation code). To do that I need to call a model method like
> user.activate or user.block, and it would be a mess probably to
> integrate this behaviour inside the update method.
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to