Forum: Ruby on Rails link_to not working derived from db

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
0daa01e327de6c68ad4d6244759fec2f?d=identicon&s=25 Artemiy Baranov (artemiy)
on 2017-02-04 19:49
Hello.

May be need another way?

<% @listtable.each do |lt| %>
  <table>
    <tr>
      <td>
        <%= lt.description %>
        <%= link_to "1", lt.tlink %>
      </td>
    </tr>
  </table></br>
<% 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
7c42bc2b2720119ba03241fd0ea91515?d=identicon&s=25 Andres Coppola (peyu)
on 2017-02-28 18:22
try to do it with button_to intead of link_to...  that should work.
790aa5104ca3a098de140f7adec3c043?d=identicon&s=25 Anusha Mummina (anushamummina)
on 2017-03-09 12:05
Artemiy Baranov wrote in post #1185526:
> Hello.
>
> May be need another way?
>
> <% @listtable.each do |lt| %>
>   <table>
>     <tr>
>       <td>
>         <%= lt.description %>
>         <%= link_to "1", lt.tlink %>
>       </td>
>     </tr>
>   </table></br>
> <% 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 topic is locked and can not be replied to.