Question

I'm using Rails 3.2.16 and inherited_resources 1.4.1. I needed a fast ad custom admin, so I used this post as example (it's still valid for rails 3.2):

http://iain.nl/backends-in-rails-3-1

This is what my routes files looks like:

  namespace :backend do
    root to: 'conferences#index'
    resources :conferences do
      resources :talks
      resources :sponsors
    end
  end

My Backend::ConferencesController and Backend::SponsorsController they both inherit from Backend::ResourceController as detailed in the blog post.

The problem I find is that whenever I go to the Sponsors index page, I get a NoMethodError:

NoMethodError: undefined method `backend_sponsor_path' for #<Backend::SponsorsController:0x007fa588113e08>

The weird thing it that the resource_path method is trying to find backend_sponsor_path instead of backend_conference_sponsor_path as declared in the routes.

Does anyone know how to solve this? Shouldn't inherited_resources be able to find the correct path?

Thanks!

Was it helpful?

Solution

OK, problem has been solved by adding belongs_to :conference to the SponsorsController:

class Backend::SponsorsController < Backend::ResourceController
  belongs_to :conference
end

Now routes are generated as expected! :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top