# Problems on "link\_to"

**URL:** <https://www.ruby-forum.com/t/problems-on-link-to/154917>\
**Category:** Rails\
**Created:** [December 5, 2008, 6:31am UTC](https://www.ruby-forum.com/t/problems-on-link-to/154917 "2008-12-05T06:31:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jette](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d9b06d/32.png) [@jette](https://www.ruby-forum.com/u/jette)\
**Post date:** [December 5, 2008, 6:31am UTC](https://www.ruby-forum.com/t/problems-on-link-to/154917/1 "2008-12-05T06:31:43Z")

</div>

I have one problem when I create the index page.

I have wrote following in index.html.erb:

## All Blogs

 \<% @weblogs.each do |page| %\> - \<%= link\_to page.title, weblog\_path(@weblogs) %\> 
 \<% end %\>

and, at first, I create on item and it’s url like this  
[http://localhost:3000/weblogs/1](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](http://localhost:3000/weblogs/1/2)

How can I solve this problem, I want the item No.1 is  
[http://localhost:3000/weblogs/1](http://localhost:3000/weblogs/1)  
and item No.2 should be [http://localhost:3000/weblogs/2](http://localhost:3000/weblogs/2)

---

<div class="post-metadata">

**Author:** ![jette](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d9b06d/32.png) [@jette](https://www.ruby-forum.com/u/jette)\
**Post date:** [December 5, 2008, 10:03am UTC](https://www.ruby-forum.com/t/problems-on-link-to/154917/2 "2008-12-05T10:03:14Z")

</div>

On Dec 5, 5:30 am, Daniel [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> \<% end %\>
> 
> 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
