I have this structure:
Enterprise
has_many :projects
Projects
has_many :clients
Clients
has_many :tasks
I'm trying to give each Enterprise a start from 1 to their tasks. So, I did:
Tasks
to_param
uid.to_s
end
And in my controllers to find a Task:
Task.find_by_uid(params[:id])
All urls are pretty, scoping the task number per enterprise. (I handle the uid at the task creation, incrementing the last uid from the same enterprise)
However, the Task.find_by_uid doesn't scope only tasks from the current_user.enterprise.
It seems to be a very noob question, by I'm struggling to find out a solution.
Please, help. Thanks.