I have an ActiveResource named Discussion. In my views, I often call
discussion_path(@discussion) and I'd like to add on the post count
(discussion.posts.count) as a get var. I'm want my urls to be like:
http://nearbygamers.com/discussions/14?posts=3 so that folks who've
read a forum see blue links for discussions that have had posts added
to them.
I've tried adding options to the discussion_path call in my views
which just blows up with various unhelpful messages (either that
"discussion url failed to generate" or a call to nil.to_sym). I've
tried writing my own discussion_path helper with similar results. Any
suggestions?
I'm having this exact same problem.
I have a route of:
map.content 'sites/:site_short_name/*file',
:controller => 'sites',
:action => 'content',
:requirements => { :site_short_name => /some_regex/ }
And I try to call
content_url :file => "search"
and it also "blows up" and says:
ActionView::TemplateError: content_url failed to generate from
{:action=>"content", :file=>"search", :controller=>"sites"}, expected:
{:action=>"content", :controller=>"sites"}, diff: {:file=>"search"}
I've looked into the rails source and this seems to be coming from:
actionpack/lib/action_controller/routing.rb line 1280 ( I have Rails
SVN revision REVISION_{2007-02-19}, so it's 1.2-ish ).
The exception seems to be raised from line 1242 in the same file
because
path = named_route.generate(options, merged, expire_on)
is returning nil...
I'm planning on reading Jamis' article: Under the hood: route
generation in Rails [ Buckblog: Under the hood: route generation in Rails
], but I haven't had a chance yet. I'm hoping there might be some help
in there.
Nate Murray
http://pasadenarb.com/