slugger
slugger

Reputation: 23

How does the model_path() method work

I'm new to ruby on rails and have been playing with some open source code in order to learn.

I am having some issues understanding what the model_path(@model) method returns and how to change it. Specifically, I have a model with an id and a slug and for some reason model_path(@model) always returns the path with the slug and not the id.

Any ideas on why this may be and how I can change this behavior?

Upvotes: 2

Views: 2998

Answers (1)

egze
egze

Reputation: 3236

model_path(@model) 

will produce this URL

/model/:id

it will substitute :id with whatever @model.to_param returns

Upvotes: 1

Related Questions