Rails method as a nested resource
Posted
by Blastula
on Stack Overflow
See other posts from Stack Overflow
or by Blastula
Published on 2010-06-07T23:55:03Z
Indexed on
2010/06/08
0:22 UTC
Read the original article
Hit count: 294
Hello, I'm wondering about the clever way to do this...
I have methods that return a value when passed an an object as parameter, such as:
<%= average_rainfall(@location) %>
I'd like to use the exact same methods as a nested resource to call via jQuery/Ajax, like so:
.load('/location/8/average_rainfall')
I understand how to define the route, but how do I tell my method to 'find' /location/8 and use that as it's parameter instead of @location as expected?
Thanks!
© Stack Overflow or respective owner