2

How to add alias to route file? Something like this:

/rules => 'posts/1', param: id => 1

Is it possible define it in routes.rb

I want

/rules => posts/1 

not

/rules/1 => posts/1

2 Answers2

2

Well, let's look at the official Rails routing guide:

You can also define other defaults in a route by supplying a hash for the :defaults option. This even applies to parameters that you do not specify as dynamic segments.

So then:

get "/rules" => "posts#show", :defaults => { :id => "1" }
Matt Brictson
  • 10,904
  • 1
  • 38
  • 43
1

try this

get '/rules', to: redirect('/posts/1')

http://guides.rubyonrails.org/routing.html#redirection

Max Williams
  • 32,435
  • 31
  • 130
  • 197
  • Better, but it must be redirect? I don't want see where redirect me. I'd like simple address /rules. That's all – dziorkowsky Mar 31 '15 at 12:09