Rails method as a nested resource
- by Blastula
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!