On 12 June 2016 at 08:03, David Alejandro <[email protected]> wrote: > I have this link in the view: > > > <%= link_to "Pay in PayPal", @order.paypal_url(edit_order_url, > payment_notification_url), class: "btn btn-success" %> > > > And this in the model: > > > class Order < ActiveRecord::Base > def paypal_url(return_url, notify_url) > # ... Do stuff > self.update_attribute(:payment_in_process, true) > # Do more stuff... > end > > When I visit the view, the model gets its attribute updated. I do not > want this. I only want the attribute updated if the link is clicked. > > Know how to accomplish this?
Separate out the code that generates the url from the code that updates the database. Then run the update in the action that is called when the link is clicked. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLspL8OBJXvsD%2BVjUhujnz28bBvH8eMjngSAB28mvBPNgQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

