Ruby-on-Rails + FriendlyId gem + Acts_as_Votable gem - getting a Heroku error -
in index page have following part of setting acts_as_votable gem.
<%= link_to like_bike_path(bike), method: :put, class: "btn btn-default" %>
it working fine until added friendlyid, because like_bike_path looking id not friendlyid (ie vanity url). there way change
like_bike_path
to like
like_friendly.find_path
works on localhost:3000 heroku logs tell me actionview::template::error (undefined method slug' #<bike"
2 acts_as_votable calls "like_bike_path(bike)" , "<%= bike.get_upvotes.size %>".
thanks!
#app/models/bike.rb class bike < activerecord::base extend friendlyid friendly_id :column, use: [:finders, :slugged] end
this allow use of slug
without having change default pattern in activerecord... (@bike = bike.find params[:id]
).
--
in regards heroku
error, means have not got database migrated (it doesn't include slug
in columns).
you need make sure run heroku run rake db:migrate
, ensuring you've re-saved @bike
records (so slug
column populated).
Comments
Post a Comment