Rails 4 + BootStrap 4 button issue -


hello have quick question can't bootstrap 4 button work in rails button code

<%= link_to 'lifehacks', controller: 'hacks', class: 'btn btn-primary' %> 

i thought work ends being apart of url instead "http://localhost/hacks?class=btn+btn-primary"

without enclosing braces, ruby treat last 2 parts of method parameters single hash when in actual fact should two.

wrapping route parameters in braces resolve issue:

<%= link_to 'lifehacks', {controller: 'hacks'}, class: 'btn btn-primary' %> 

from documentation, can see how these defined:

link_to(name = nil, options = nil, html_options = nil, &block)

without explicit wrapping, both controller , class options being passed options rather class element being passed html_options.


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -