Another thing I might point out is that I'm just interested in sharing 
methods between these 4 models. If I were to go the new class that the 
models inherit from route, that new class would never be instantiated. 
With that in mind, it seems to be more sensible to go the module route 
to me.

-- Josh
http://iammrjoshua.com

Joshua Abbott wrote:
> I'm curious to get some feedback from the smart people around here.
> 
> I've got a method called "to_permalink" that creates a URL friendly
> permalink from the name, or title attribute of about 4 AR models.
> 
> For those same models I want to override the "to_param" method so it's
> formatted like
> 
> "#{id}-#{permalink}"
> 
> 
> It's obviously not too DRY to define to_permalink and redefine to_param
> in each model and the two obvious solutions would be:
> 
> 1.) Create a new class that these 4 AR models would inherit from.
> 
> 2.) Add a module to lib and include that in these 4 models.
> 
> Either way works, but I'm wondering is there a convention for this type
> of thing? Any caveats to using one vs. the other? If it's the same
> either way, then what is the most readable in your guys' opinions?
> 
> Let me know what you guys think, or if I've missed something altogether.
> 
> Thanks,
> -- Josh
> http://iammrjoshua.com

-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to