On May 19, 11:29 am, Marnen Laibow-Koser <
li...@ruby-forum.com> wrote:
>
frankjmat...@gmail.com wrote:
> > yeah, i've read it half a dozen times
>
> Read *what*? Please quote when replying so it's clear what you're
> responding to.
I have read the rails routing guide a dozen times.
> > - doesn't give me any insight on
> > the argument list for the _path family of functions and apidock is
> > less than helpful as well.
>
> Are you talking about the routing guide?
Yes.
> In any case, the arguments are whatever is defined in that particular
> route. Run rake routes or look at your routes file to see what that
> would be.
That doesn't make any sense. My output of rake routes does not show a
function name for put requests. What I've discovered
(through trial and error) is that when using a _path function the
arguments can either be in the form of
_path(:id => @station)
_path(@station)
_path(@station, :attribute_not_on_the_model => :value)
_path(@station, :station => { :this_attribute_is_on_model => :value})
where in the guide is that explained? if it's even in there it most
certainly is not clear unless you already have a very good grasp of
the subject. I don't believe that it's "typical" for someone reading
the guides (mostly beginners I'll assume) to want to pass params in
their links and send them off as put requests.
> > searching through google led to some obscure blog that said i could
> > do:
> > link_to 'do something', station_path(@station, :station =>
> > { :attribute => :value }), :method => :put
>
> > but why does this work and why aren't the _path functions clearly
> > documented?
>
> Because they're generated from your routes, and so will be different for
> each Rails app. This is pretty clearly explained in the routing guide,
> as well as in the documentation for ActionController::Routing and
> ActionController::Resources . Perhaps you should read those again.
ActionController::Resources is the only one of those that even hints
at the proper form for the _path functions and that's only in the very
first example which doesn't even say that it can be used for those
functions - it only says "this is what a so-and-so request looks
like".
http://rails.rubyonrails.org/classes/ActionController/Resources.html
to quote the docs a little further down it says:
Named Route Helper
message message_url(id), hash_for_message_url(id),
message_path(id), hash_for_message_path(id)
that would lead me to believe that the only argument available to
those functions is id...
> > maybe someone who knows could point me to where these functions are
> > defined in the source tree (preferably in master)?
This is all I'm really interested in now. Simply for curiosities
sake... The rest I've figured out and is all moot.