Link_to not working derived from db

Hello.

May be need another way?

<% @listtable.each do |lt| %>

<%= lt.description %> <%= link_to "1", lt.tlink %>
<% end %>

DB => [#<ListTable id: 1, description: “test 1”, tlink: “root_path”,
created_at: …

In my case, instead of localhost:3000, substituted the string
localhost:3000/root_path

try to do it with button_to intead of link_to… that should work.

Artemiy Baranov wrote in post #1185526:

Hello.

May be need another way?

<% @listtable.each do |lt| %>

<%= lt.description %> <%= link_to "1", lt.tlink %>
<% end %>

DB => [#<ListTable id: 1, description: “test 1”, tlink: “root_path”,
created_at: …

In my case, instead of localhost:3000, substituted the string
localhost:3000/root_path

As you are storing root_path as a string link_to is not recognizing it
as a path instead it is taking as a string.

try like this:

<%= link_to “1”, public_send(lt.tlink) %>

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs