friendly-id

Redirect same page to different language with Globalize & Friendly_id

做~自己de王妃 提交于 2019-12-05 04:16:55
I've been scratching my head for the last few hours, looking for an answer but I can't find it anywhere. My gem file: # Use globalize for translating models gem "globalize", github: "ncri/globalize" # for Rails 4.2 gem 'globalize-accessors', '~> 0.1.5' # Use friendly_id for slugs gem 'friendly_id', '~> 5.1.0' gem 'friendly_id-globalize', '~> 1.0.0.alpha1' Here's the situation: I have two languages "en" and "fr" 2 models : pages and pages_translations pages has a slug column, pages_translations also has a slug column. if I view the page -> en/pages/slug-en, it works. if I view the page -> fr

Rails 4 Friendly Id Slug Not Updating

早过忘川 提交于 2019-12-04 15:40:12
问题 I'm using the following: gem 'friendly_id', github: 'FriendlyId/friendly_id', branch: 'master' I am creating an Article section on my Rails 4 website. The problem I am having is that when I change a existing article's name the slug is not updated. This is what I have so far: extend FriendlyId friendly_id :name, use: :slugged add_column :articles, :slug, :string add_index :articles, :slug, unique: true 回答1: In FriendlyId 4 (Rails 3 compatible) there was a method should_generate_new_friendly_id

friendly_id and real id

a 夏天 提交于 2019-12-04 13:05:17
Is there any way to get the real id column from a model that is modified with friendly_id? I don`t want to make another db query for it, in performance reasons. Broadly speaking friendly_id modifies to_param and find methods. Next should work: @affiche = Affiche.find(params[:id]) # params[:id] is a slug @id = @affiche.id Have you tried attributes["id"] ? e.g: Model.first.attributes["id"] 来源: https://stackoverflow.com/questions/7944908/friendly-id-and-real-id

Rails4 Friendly_id Unique Slug Formatting

天大地大妈咪最大 提交于 2019-12-04 10:53:09
问题 I am using friendly_id gem for slugging my models. Since the slug has to be unique when i enter the same data to check i get a long hashed appending in the slug. Explore explore Explore explore-7a8411ac-5af5-41a3-ab08-d32387679f2b Is there a way to tell friendly_id to give better formatted slugs like explore-1 and explore-2 Version: friendly_id 5.0.4 回答1: Agreed, it seems like pretty rough behavior. If you look at code of friendly_id/slugged.rb , there are 2 functions handing conflicts

How can I use friendly ID in Rails like mysite.com/[USERNAME]

一曲冷凌霜 提交于 2019-12-04 07:25:25
How can I use friendly URLs on my Rails application ? All I need is to make available the following url format mysite.com/company1 mysite.com/user123 mysite.com/user1234 mysite.com/newton.garcia mysite.com/company-name Can anyone help ? I already ask this question on Quora.. http://www.quora.com/How-does-Quora-rewrite-their-urls For who really interested to implement Quora/Facebook URLs like. Heres a tip in Rails3: Make a table called slugs : # slug | model_id | model # =========================== # simple data: # one | 2222 | post # two | 1111 | user # six | 5432 | comment Now in routes.rb

Match multiple models in single Rails route with friendly_id

最后都变了- 提交于 2019-12-03 22:53:44
问题 I have a Company and a User model, both with a slug via friendly_id. Slugs are ensured to be unique across both models. I'd like to have URLs: http://www.example.com/any_company_name http://www.example.com/any_user_name e.g. both /apple and /tim I'm not sure how to achieve this in Rails. I have tried various permutations of: routes.rb: resources :users, path: '' resources :companies, path: '' get '*search', to: 'my_controller#redirect' and my_controller#redirect: @company = Company.friendly

Change the unique generated title names of friendly-id

随声附和 提交于 2019-12-03 15:43:19
I am using the friendly_id gem. In the portfolio.rb I placed these two lines: extend FriendlyId friendly_id :title, use: :slugged As you can see I am also using the slug option. When I create a project with title "example" it works find and I can find the project under mysite.com/projects/example . Now, if I create a second one with the same title I get a title for it like this one: mysite.com/projects/example-74b6c506-5c61-41a3-8b77-a261e3fab5d3 . I don't really like this title. I was hoping for a friendlier title like example-2 . At this question , RSB (user) told me that its friendly_id

Rails 4 Friendly Id Slug Not Updating

会有一股神秘感。 提交于 2019-12-03 09:46:52
I'm using the following: gem 'friendly_id', github: 'FriendlyId/friendly_id', branch: 'master' I am creating an Article section on my Rails 4 website. The problem I am having is that when I change a existing article's name the slug is not updated. This is what I have so far: extend FriendlyId friendly_id :name, use: :slugged add_column :articles, :slug, :string add_index :articles, :slug, unique: true Mike Szyndel In FriendlyId 4 (Rails 3 compatible) there was a method should_generate_new_friendly_id? and you could define it on your model to control when slug is regenerated. Try def should

Rails4 Friendly_id Unique Slug Formatting

天涯浪子 提交于 2019-12-03 06:56:19
I am using friendly_id gem for slugging my models. Since the slug has to be unique when i enter the same data to check i get a long hashed appending in the slug. Explore explore Explore explore-7a8411ac-5af5-41a3-ab08-d32387679f2b Is there a way to tell friendly_id to give better formatted slugs like explore-1 and explore-2 Version: friendly_id 5.0.4 Agreed, it seems like pretty rough behavior. If you look at code of friendly_id/slugged.rb , there are 2 functions handing conflicts resolution logic: def resolve_friendly_id_conflict(candidates) candidates.first + friendly_id_config.sequence

Generating a unique URL with tokens in Rails 4 for an external form response

孤街浪徒 提交于 2019-12-03 04:36:51
问题 I have a 'Feedback' model whereby a user should be able to request feedback on his/her job performance. I have written basic actions for creating a new feedback request, and the mailer for sending the request to the provider (person who will respond with feedback). I would like advice from the community on implementing the following: Once a new feedback request is created, the email that is sent should contain a link to a form where the provider can input his feedback on the users performance