Skip to content

Best practice for Notifications on a single model that can be created multiple different ways. #85

Answered by excid3
diericx asked this question in Q&A
Discussion options

You must be logged in to vote

Great question! You can really set it up however you like.

For polymorphic comments, I've actually setup namespaced controllers and include shared functionality with a concern. This makes it so you can branch out as necessary if you want comments to work slightly different for one model than another. Most of the time I don't override anything though.

In your url method, the only non-standard thing I see is the wiki_page_path that makes that conditional required.

There should be a way to override to_param or something on your Page model to automatically include the Wiki ID. I believe something like this should work:

class Page
  def to_param
    "/wikis/#{wiki.id}/pages/#{id}"
  end
end

Th…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by excid3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants