Ask A Question

Notifications

You’re not receiving notifications from this thread.

Share scopes/nested routes/inherited resources?

Ash Joseph asked in Rails

I'm in the process of learning Rails (loving it so far) and my play project (A task list, obvs) is structured a little like this:

Task -> belong to project/project has many tasks
Task has scopes for status, along the lines of:

scope :newest, -> { order(created_at: :desc) }
scope :oldest, -> { order(created_at: :asc) }
scope :priority_low, -> { order(priority_level: :asc) }
scope :archived, -> { where(archived: true) }

But I'd also like all of this shared on the project level for when I start implementing search and filtering.
This kind of thing:
So I'd like to do projects/id/task/id?complete=true

I've had a look through the guides (They are so comprehensive) but couldn't find anything that jumped out. Is there something in place so I can have projects inherit this all or do I need to duplicate the work?

Thanks in advance :)

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 86,140+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.