# Resource vs resources

**URL:** <https://discuss.rubyonrails.org/t/resource-vs-resources/59829>\
**Category:** rubyonrails-core\
**Created:** [July 12, 2011, 8:23pm UTC](https://discuss.rubyonrails.org/t/resource-vs-resources/59829 "2011-07-12T20:23:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![elfo](https://avatars.discourse-cdn.com/v4/letter/e/58f4c7/32.png) [@elfo](https://discuss.rubyonrails.org/u/elfo)\
**Post date:** [July 12, 2011, 8:23pm UTC](https://discuss.rubyonrails.org/t/resource-vs-resources/59829/1 "2011-07-12T20:23:00Z")

</div>

There seems to be a small bug with has\_one relationships and resource in the routes. Example:

where beta has\_one alpha

In routes: resource alpha

In view:

form\_for @alpha --\> automatic link is alpah\_path(id) and not alpha\_path and in this case since there is no id in the route, the id takes the place of the format param -\> /alpha.1

Thanks! Mike

---

<div class="post-metadata">

**Author:** ![sikachu](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/sikachu/32/628_2.png) [@sikachu](https://discuss.rubyonrails.org/u/sikachu)\
**Post date:** [July 12, 2011, 10:17pm UTC](https://discuss.rubyonrails.org/t/resource-vs-resources/59829/2 "2011-07-12T22:17:31Z")

</div>

There have been a lot discussion about this a while ago. However, we couldn’t find the way to determine the correct route to use when you have a singular resource, so it was left unfixable.

The solution you’ll have to do is to use `:url`

form\_for @alpha, :url =\> alpha\_path

---

<div class="post-metadata">

**Author:** ![Corin\_Langosch](https://avatars.discourse-cdn.com/v4/letter/c/ec9cab/32.png) [@Corin\_Langosch](https://discuss.rubyonrails.org/u/Corin_Langosch)\
**Post date:** [July 13, 2011, 7:20am UTC](https://discuss.rubyonrails.org/t/resource-vs-resources/59829/3 "2011-07-13T07:20:52Z")

</div>

What about making the polymorphic routing in rails to try a plural route first. If it fails, try a singleton route. If it fails, raise.

```
This is not the nicest and most performant way (the result could be

```

cached in production so it doesn’t really matter in the end) but I guess it should solve most cases. Or is this too much magic?

```
Corin

```

---

<div class="post-metadata">

**Author:** ![sikachu](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/sikachu/32/628_2.png) [@sikachu](https://discuss.rubyonrails.org/u/sikachu)\
**Post date:** [July 13, 2011, 11:50am UTC](https://discuss.rubyonrails.org/t/resource-vs-resources/59829/4 "2011-07-13T11:50:31Z")

</div>

I was thinking about the same thing too, but something was blocking me at that moment. Do you mind digging into the source code and see if it’s possible from your perspective, and then send a pull request if you can patch it?

Thanks a lot! 🙂

---

<div class="post-metadata">

**Author:** ![Andrew\_White](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/andrew_white/32/1481_2.png) [@Andrew\_White](https://discuss.rubyonrails.org/u/Andrew_White)\
**Post date:** [July 13, 2011, 11:50am UTC](https://discuss.rubyonrails.org/t/resource-vs-resources/59829/5 "2011-07-13T11:50:39Z")

</div>

That's certainly one of the solutions I've thought about and I've got a GitHub issue (#1769) assigned to me regarding this issue so it's on my todo list once 3.1 has shipped.

Andrew

---

<div class="post-metadata">

**Author:** ![sikachu](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/sikachu/32/628_2.png) [@sikachu](https://discuss.rubyonrails.org/u/sikachu)\
**Post date:** [July 13, 2011, 11:52am UTC](https://discuss.rubyonrails.org/t/resource-vs-resources/59829/6 "2011-07-13T11:52:43Z")

</div>

ORLY? I didn’t see that ticket. Lemme have a look!
