Passing Params to href in Rails -


i reading other engineers code undersntad stuff , here one:

  %a{href: scores_organizations_path(organization_id: summary.id), class: ('not-eligible' unless summary.scores_score.present?)} 

the part passing parameter _path new me, had never seen before.

<a href="/scores/organizations?organization_id=6297552"> 

this intresting, can dynamically pass params links?

where in rails guides? or other reaource can read more details , learn it.

thanks.

you can read more routing here:

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

although, code seem bit strange. write same thing such:

= link_to "link title", scores_organizations_path(@organization) 

as can see, there's no need specify id manually. translates to:

/scores/organizations/:id 

you still pass optional params:

= link_to "link title", scores_organizations_path(@organization, foo: 'bar') 

you can read more on link helpers here.


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -