Search code examples
ruby-on-rails-4viewmodelhelpermethods

How set up and call a rails method in the view to update an attribute of an object


I need some help in figuring out how to set up a helper method and then call in in the view. What i need to do is update a single attribute of a model object.

How I plan to do this is to call a helper method Bid, which will update the attribute by the same increment every time, for example, by one dollar.

Then, I need a way to call this helper method in the view and update the auction attribute current_price and display it in the view. Any ideas on how this could be done? Thanks


Solution

  • Just update the price in the controller and pass the Bid instance to the view. In the view, you call something like:

    @bid.price
    

    To access the price of the current bid.