You’re not receiving notifications from this thread.
Pretty urls with FriendlyID Discussion
Why are you able to use find_by_slug? Are you using the deprecated finders gem?
Awesome. Also cool that you showed process for doing it manually. Sometimes these ruby gems seem like magic if you just use the gem without first trying to do it yourself.
In real project, should we use integer for userId? How about if 2 different user signup at the same time and who will be assigned 1 or 2?
I couldn't make this work with cancancan :(
Any thougts on how to make it work?
Cancan makes a good amount of assumptions that you are doing the normal Rails lookups here. There are a handful of different ways to make them work together, but the best one I've seen is to not use the load_resource and to authorize in the action instead: https://github.com/norman/f...
Muchas gracias el tutorial me ayudo mucho lo estoy implementando en un proyecto que tengo jejeje muchas gracias
Thanks very much the tutorial help very well thanks
Hi, Chris great tutorial ones again. However I have all ready application on the DigitalOcean and now I have to deploy the Friendly_url to it. I use the postgres db so how I can update all records from the table? So the url ID´s will show by name? In the local version sqlite I can you the Profile.find_each(&:save) and it works. But how on the production postgres version?
This is exactly what I want to talk about in a future episode (basically deploying breaking changes to production).
You have a bunch of options:
A hacky way to do it would be to create a new migration or edit the friendly_id migration to re-save all the profiles. This will do the trick with only one deploy. You shouldn't have any downtime with this approach, but you're heading into territory that can break migrations if you don't do it right. Future you might get frustrated with this hack, but it's certainly the easiest solution.
Another way to do it would be to create a rake task that you can run with Capistrano that runs the profile save. Or simply SSH into the server and run that code in the Rails console after deploy.
The ideal solution (if you need absolutely 0 downtime) is to figure out how half-deploy the update. Basically migrate the database and make save all records (and any new ones) with the new slug code but don't update the controllers to use the new IDs just yet. Once you've deployed that code safely and all the records now have a friendly_id, you can then do a second deploy that changes the URLs everywhere to use the new ones. This is obviously much more involved, but a common practice when you're doing things in production that can't have any downtime.
Get as complicated as you would like to with it, but you're probably fine just deploying the changes and running the save in an SSH rails console if you don't mind a few seconds of possible broken links. That's usually what most people do until they have tons of traffic.
Say for example I have a reservations model nested inside a rooms model. After implementing friendly_id, my reservations try to save as the room's friendly_id slug instead of the room's ID (integer). How do I make it save by the integer instead?
I was thinking about this yesterday, thanks, this is nice feature to make a friendly SEO site
Chris, thanks for the video once again and happy thanksgiving!!! I'm getting the following error in the attached screenshot, any ideas? https://uploads.disquscdn.c...
How can I solve the problem on parameterizing two-byte characters (ex. Korean, Japanese, Chinese). Would you hint me to solve it?