Hi everyone,
Im just trying out the new restful routes in Rails. Im having trouble
though.
hash_for_resources_url.inspect
=> {:use_route=>"resources",
:controller=>"resources", :action=>"index",
:only_path=>false}
as expected
but then:
hash_for_resource_url(@resource).inspect
=> cannot convert Resource into Hash
What happened?
so I tried:
hash_for_resource_url(:id => @resource).inspect
=> {:id=>#, @errors={}>,
@attributes={"title"=>"resource_title",
"id"=>"1"}>, :controller=>"resources",
:use_route=>"resource",
:action=>"show", :only_path=>false}
Nope.
No to_param in there?
hash_for_resource_url(:id => @resource.to_param).inspect
=> {:id=>"1", :controller=>"resources",
:use_route=>"resource",
:action=>"show", :only_path=>false}
Right thats what I wanted.
At least I think that''s what I wanted. Is it supposed to work like
that? Doesn''t seem very useful. And the docs say it works by passing
in
the id (hash_for_message_url(id))
I guess my question is what are some possible uses of
hash_for_resource_url that make this functionality appropriate? Im
still new to all this.
What I wanted to do was pass the hash into the activerecordhelper#form
method (never seen that method before today, neat). But then when I got
hash_for_resource_url figured out I realized that there is only
hash_for_new_resource_url and hash_for_edit_resource_url. but no
hash_for_update_resource_url, etc. So.. Gosh Im just confused I guess.
Can anyone maybe point me in the direction of some good clarifications
of these new generated routes and how they are intended to be used.
Maybe I should ignore all these new fancy named routs and just write
them out like I always have (as controller action id hashes)? Dunno.
Still testing the waters I guess.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---