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?