I have already setup Friendly Id following all the instructions from the Home page.
In short,i have added the module
and slug
column in my Place model table.
in my place.rb
extend FriendlyId
friendly_id :name, use: [:slugged, :finders, :history]
I also ran Place.find_each(&:save)
.
Now the value of name
can be different,as there are many places with same names.So in the index action when i call the show action,using id
,i get correct results but urls looks bad,However,when i call show action using friendly_id
,url is bad here too with its uniq token like string attached and also i always get wrong result.
for example. For a record with name
value as burwood,there can be multiple entries too.However,there are two problems:-
- My urls should be like
http://ift.tt/2jWFm6I
instead ofwww.mysite/sydney/21
,if i am usingid
and notfriendly_id
(which looks weird - http://ift.tt/2kgmhsg),How to handle this. ?? - If i dont use Id and use
friendly_id
as url parameter,For similar locations of value burwood,i am always get first record even if i am asking for other one.So in DB,name
value ofburwood
having two records,my slug values are different -burwood
andburwood-78894aa3-dea1-4915-b2f7-038182511005
So if use id as url parameter,it works as id's are uniq and slugs are not considered but i want url to be more meaningful.
However,if i use friendly_id,url looks weird and also unique record is not picked up.
Kindly help
Aucun commentaire:
Enregistrer un commentaire