2
votes

How to correct write this record? When I write the following code, which you can see in this post I have received following mistake: undefined method `stringify_keys' for "/plant/index":String

Html code

<li class="new_button">
<%= link_to "Plants", plant_path, :class=>"greens" do %>
<span></span>
<% end %>
</li>

I need (just with link_to)

<li class="new_button"><a href="#" class="greens">Plants<span></span></a></li>
2

2 Answers

2
votes

If you pass block into link_to, first argument is responsible for evaluating proper link href and second argument is assumed options. In your example, second argument is returned value of plant_path, which is String instance, but Rails want to evaluate it as Hash. What you should do is:

<%= link_to plant_path, class: 'greens' do %>
  Plants<span></span>
<% end %>
0
votes

Try this

<%= link_to plant_path, :class=>"greens" do %>
 <span><%= "Plants" %></span>
<% end %>