I would like to produce this link:
<a href="/settings" class="button"><span class="magnifier icon"></span>Search</a>
So as far as I understand it I have to convert
<%= link_to "Upgrade", :settings, :class => "button" %>
To a block, but when I do this:
<%= link_to "Upgrade", :settings, :class => "button" do %>
<span class="magnifier icon">Search</span>
<% end %>
It gives me the following error:
undefined method `stringify_keys' for :settings:Symbol
However, when I do: <%= link_to "Upgrade", :settings, :class => "button" %>
it works perfectly.
How do I convert this to a block ?
Rails Rails 4 requires Ruby 1.9 or later. Rails 5 requires Ruby 2.2 or later. Rails 6 requires Ruby 2.5 or later.
When using a block, the first argument no longer contains the link content. The block is responsible for that. Therefore, it thinks that "Upgrade"
is your link's destination and :settings
is your options hash.
Remove "Upgrade"
and put it in the block.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With