I’m converting our app into restful rails. A couple of my classes
(Resource and Asset) have a has_many relationship with each other -
here’s the routes:
map.resources :assets, :has_many=>[:resources]
map.resources :resources, :has_many=>[:assets]
I’m getting something weird in my view pages. When i go to
/resources/4/assets
it works. I go to the page again (just hitting enter in the address
bar) and i get the error below. I restart mongrel and it works again.
Refresh again and it breaks again: every time. I can go to a different
url (eg /resources/4) and its fine: come back and its broken again. My
colleague, running the same code on his mac (i’m using ubuntu linux)
doesn’t get the error.
Has anyone seen anything like this before? I’ve only got it since we
started using restful rails. I’ve tried rebooting. I’ve tried running
webrick instead of mongrel. No joy…
Here’s the trace: it seems like it has an issue with my nested path
helper, “resource_asset_path”.
Showing assets/index.html.erb where line #13 raised:
stack level too deep
Extracted source (around line #13):
10:
11:
12:
13:
%>
14:
15:
asset), :confirm => ‘Are you sure?’, :method => :delete %>
16:
RAILS_ROOT: /home/jars/rails/lesson_planner/branches/bundles
Application Trace | Framework Trace | Full Trace
/usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/attribute_methods.rb:186:in
method_missing' /usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/attribute_methods.rb:194:in
method_missing’
/usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1948:in
to_param' (eval):2:in
resource_asset_path’
app/views/assets/index.html.erb:13:in
_run_erb_47app47views47assets47index46html46erb' app/views/assets/index.html.erb:9:in
_run_erb_47app47views47assets47index46html46erb’
/usr/bin/mongrel_rails:19:in `load’
/usr/bin/mongrel_rails:19