Home > Net >  Correct way to use nested link_to?
Correct way to use nested link_to?

Time:07-27

<%= link_to controller: :personal_data, class:"px-6 py-4 flex items-center text-sm font-medium" do%>
    <span >
       <span >01</span>
    </span>
    <span >Personal Data</span>
<% end %>

The view seems to make it that the class attribute is a GET function. Here's the generated HTML

<a href="/personal_data?class=px-6 py-4 flex items-center text-sm font-medium">
    <span >
          <span >01</span>
    </span>
    <span >Personal Data</span>
</a>

How should I write it so that the class would be working as it should be?

CodePudding user response:

You can set url using personal_data_path

<%= link_to personal_data_path, class:"px-6 py-4 flex items-center text-sm font-medium" do%>
    <span >
       <span >01</span>
    </span>
    <span >Personal Data</span>
<% end %>
  • Related