Link_to not working derived from db


#1

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


#2

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


#3

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) %>