Help with RESTful named url options

I’ve found quite a few posts on the subject, but no satisfactory
answers. Maybe Rails just doesn’t support this yet.

How do I create a url with a named RESTful route that also has
parameters?

I want to write this:

link_to_remote “Show Details”, {:url => item_url(@item, :details =>
1), :method => :get}

And get this:

Show Detail

Instead I get:

You have a nil object when you didn’t expect it!
The error occurred while evaluating nil.to_sym

/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/core_ext/hash/keys.rb:27:in symbolize_keys' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/ base.rb:518:ininject’
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/core_ext/hash/keys.rb:26:in symbolize_keys' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/ helpers/url_helper.rb:21:inurl_for’
(eval):19:in `item_url’

My best workaround has been to do:

link_to_remote “Show Details”, {:url => item_url(@item) + “?
detail=1”, :method => :get}

Which doesn’t seem like the Rails way.

I’m not using a route like: items/1;detail and a helper like:
detail_item_url(@item), because I have mutliple parameters which I can
mix and match to change the view. It creates too many custom named
routes.

Thanks,
Ryan

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs