Change From :Id in URL in Rails 3 Routing -


boy seems piece of cake, can't find in routing bible --

is there way change default parameter ':id' else ':pid' without using 'match /post/:pid'? want avoid using 'match' because feels particularly brittle.

edit confirm, success if can do:

pid = params[:pid] 

doing:

pid = params[:id] 

works already, wrong code, because it's not id in there.

you can define to_param method in model:

def to_param   pid end 

then of generated links, etc. use pid instead of id. , in controller, params[:id] give pid, not id.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -