Wordica
Wordica

Reputation: 2597

Rails SEO friendly URL

I got long brake from RoR and have some problem:

I have this URL:

http://www.xxx.zz/blog_posts/misieq?tit=some-fraze-in-here

How can I change "?" for params on "/" ?

This URL is created by:

<%= link_to f.title, blog_post_path( :tit => f.slug ) %></div>

Or how can I make most SEO friendly URL - I already use friendly_id gem

Upvotes: 0

Views: 310

Answers (1)

Tobias
Tobias

Reputation: 4653

Add a route to your routes.rb file which includes the tit paramter directly in the path.

For example:

Rails.application.routes.draw do
  get 'post/:tit' => 'posts#show', as: :blog_post
end

Of course you have to adjust the routes to your needs.

Just have a short look into this question. It doesn't matter if you have parameters in the URL anymore.

Upvotes: 2

Related Questions