bourne
2011-Jan-09 16:04 UTC
Clarification on best practice (nested ressources and routes)
I want to ask for your advise on best practice in Rails3. Let take a simple model consisting of users und tasks. In the model, one user has many tasks, every task belongs to an user. I do not really "work" with the users, as this is the Devise-Table and I just link the other data to the users logged in. (This is not a real world sample, just a situation simple enough to discuss). In my routes I could go with resources :users do ... resources :tasks do member do ... end end end This gives me longer URLs with users, ids, task and ids. I could as well put all my stuff in the tasks-controller and set the following routes: devise_for :users resources :tasks do collection do ... end end root :to => "tasks#index" In my tasks controller I need to take care of handling the correct behaviour of users and tasks (only show tasks belonging to users or add new tasks to the user logged in). Beside from that, is that against coding practice and opens door to hell or is this a way one can go? -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.