Forum: Ruby on Rails Problems on "link_to"

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.
3949b43a989430f9959e816e105cbbcc?d=identicon&s=25 Jette Chan (jette)
on 2008-12-05 06:31
(Received via mailing list)
I have one problem when I create the index page.

I have wrote following in index.html.erb:

<h2> All Blogs</h2>
<ul>
  <% @weblogs.each do |page| %>
    <li>
      <%= link_to  page.title, weblog_path(@weblogs) %>
    </li>
   <%  end %>
</ul>

and, at first, I create on item and it's url like this
http://localhost:3000/weblogs/1
It just works fine for me.

But when I've created the second item, the url of both 2, became like
this http://localhost:3000/weblogs/1/2

How can I solve this problem, I want the item No.1 is
http://localhost:3000/weblogs/1
and item No.2 should be http://localhost:3000/weblogs/2
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-12-05 10:03
(Received via mailing list)
On Dec 5, 5:30 am, Daniel <cho...@gmail.com> wrote:
>    <%  end %>
> </ul>
>
> and, at first, I create on item and it's url like thishttp://localhost:3000/weblogs/1
> It just works fine for me.
>
Well the argument you're passing to weblog_path is the entire
collection of weblogs which doesn't seem right (especially when you've
already got a variable page that will iterate over the members of that
collection

Fred
This topic is locked and can not be replied to.