On Sep 15, 3:44 am, Sijo Kg <[email protected]> wrote:
> in routes.rb
> map.resources :projects do |project|
>   project.resources :assessments do |assessment|
>     assessment.resources :findings
>   end
> end
> --

I'd consider adding :shallow => true. There is a lot of stuff out
there about deeply nested routes (you don't need them!). Three deep is
not necessarily deep, but you only need two in any case (parent/child)
and only one in a lot of cases (edit/show)

You really only need:
  /assessments/1/findings/1/
Since assessment(1) knows who its parent is (project(1)).

It is strange that I found a post that seems to be trying to solve a
similar real world problem with RoR and believe me it is a real
learning experience. While I've be playing with rails for years I've
only tried to develop a complex application recently. Consider:

  map.resources :companies, :shallow => true  do |company|
    company.resources :projects do |project|
      project.resources :jobs do |job|
        job.resources :stages  do |stage|
          stage.resources :stage_assessments
          stage.resources :assessments, :through
=> :stage_assessments, :only => [:index]
          stage.resources :citizens, :through => :citizen_stages
          stage.resources :citizen_stages
        end
      end
    end
  end

and

  map.resources :assessments, :member => {:post => :post, :display
=> :get, :clone => :get, :application => :get },:shallow => true do |
q|
    q.resources :questions, :member => {:duplicate => :get}, :shallow
=> true do |a|
      a.resources :answers
    end
  end

And this is just a draft version - there is even more! This is really
a dual application (maybe should be two). One side is project
management where the customers projects consist of finding people
(citizens) for jobs. The citizens go through a number of stages/phases
(application, interview, training, etc). Each stage can have multiple
assessments. In other words it job applicant screening process and
those with the best scores in a phase move on to the next phase. I
should point out that the stages and assessments can be customized for
each job. The assessments mapping allows you to build or clone
assessments that can be customized.

I think my major problem was trying to build this application was
experimenting! That is generating the CRUD resources and then trying
to define the resource route mapping. I should have started with the
routes and defined "how" I was going to do things (the flow).

Steve



> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to