#7 ✓moved_to_github
Brian McManus

More contextual_views questions.

Reported by Brian McManus | June 10th, 2009 @ 12:55 PM

So I added a nested resource (Screenshots) to my main model. I have contextual_views turned on. When I go to model/[id]/screenshots I get an error because resourcelogic is having rails look for my template in screenshots/model/index.erb.

Is this the expected behavior? I would not consider the parent object to be a "context" in this case. Not to mention that I would have thought at the very least it would look in screenshots/model/root/index.erb?

Now I am using contextual_views so I do have a context for the parent model which I would expect to be respected by the children. Here's what I was expecting but maybe I'm crazy.

Say this is routes.rb:

  map.with_options(:path_prefix => "dashboard", :name_prefix => "dashboard_") do |dashboard|
    dashboard.resources :models, :has_many => :screenshots
  end
  map.resources :models, :has_many => :screenshots
  map.resources :screenshots

So my "contexts" would potentially be dashboard or root.

Assuming contextual_views:
* If I go to model/[id]/screenshots I would think it would look in screenshots/root for index with screenshots scoped to the parent model. * If I go to dashboard/model/[id]/screenshots I would think it would look in screenshots/dashboard for index again scoped to the parent model. * If I go to screenshots/ I would think it would again look in screenshots/root but be scoped to Screenshot instead of the parent model.

Maybe I'm just way off base here and the parent model should really be part of the context but I would think a "screenshot is a screenshot" besides you can check if you have a parent object other ways to figure out if you need to do something different for some reason. If you want to leave the parent model as part of the context then shouldn't it have at least been looking in screenshots/model/root/?

Comments and changes to this ticket

  • Ben Johnson

    Ben Johnson June 10th, 2009 @ 01:25 PM

    • State changed from “new” to “open”

    Hi, that is the whole point of resourcelogic, it allows you to easily nest resources. You need to do:

    belongs_to :parent
    

    In your controller that is being nested. Are you doing that?

  • Ben Johnson

    Ben Johnson August 7th, 2009 @ 06:34 PM

    • State changed from “open” to “moved_to_github”

    [state:"moved_to_github" bulk edit command]

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Adds context into the RESTful development style.

People watching this ticket

Pages