user1946705
user1946705

Reputation: 2888

Rails 3 - how to solve different count of parameters in URL

I am thinking about question in routing... I have for example following in URL:

example.com/john

and for this URL I did this in routes

match "*a" => "people#person"

and in controller def profile #I have "john" in params[:a] variable ... end

And know I am thinking, how to do following URL

example.com/john/something

How I should edit my routes and my controller for this shape of URL. I am newbie in Rails, and a bit confused yet in routing...

Thank you

Upvotes: 0

Views: 223

Answers (1)

fl00r
fl00r

Reputation: 83680

match ":a(/:b)" => "people#person"

# controller
def person
  a = params[:a]
  b = params[:b]
end

Upvotes: 3

Related Questions