ruby on rails - link_to helper method not working with friendlyId Gem in production -
it's strange works on dev environment when deploy continues link product id.
i using rails 4.04 , friendlyid v5 gem. on development when this:
<%= link_to image_tag(product.photos.first.image.url(:feed)), product %>
it generates picture link looks this:
http://localhost:3000/products/my-product-slug
but when deploy production same code generates
http://myprodserver.com/products/68
why happening?
as discussed you, problem explicitly generating slug
field in model.
though have correctly configured friendlyid
in model - in production, there still many products slug
field may not have value. need generate slugs them before can access route correctly (as intended).
i take slug generation part in sort of callback. so, in production, can do:
product.find_each(&:save)
create slugs.
friendlyid should work perfectly! :)
good luck. :)
Comments
Post a Comment