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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -