On Rails 3.2.1. I have a model called Car with an attribute called rate (indicates a price quantity). I’m using the ajaxful_rating gem which associates a method called rate (to submit a rating of how good a teacher is) with a Car.
So in my view, when I’m trying to show a price quantity with:
<%= @car.rate %>
I get a syntax error because there’s naming confusion. How do I let Rails know that I want to call the rate attribute and not the rate method? Is there an easy way to resolve this without rolling back my DB and renaming the attribute?
You can use
read_attribute:but I suggest that you resolve the conflict by renaming one of them as it will just cause you problems and confusion down the road.
You don’t need to rollback your database to rename a column, you just have to create a new migration that does so.