I want to add some functionality to DateTime and stuff. I''m not sure how I would go about extending it though...would I modify the class itself in the core, extend it in another class, etc? Also, I don''t see where I''d put it in my rails application....thanks! --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Put it in the lib directory. It doesn''t matter what name you give it. Ruby classes are cool in regards to being able to add functionality. In other languages, doing: class DateTime #blah end when there''s already a DateTime class defined might throw an error! Thankfully, Ruby understands that sometimes we want to add to something so doing class DateTime code end Will add that code to the DateTime class. Out of interest, what code are you adding to it? On Dec 6, 2007 11:12 AM, Mike C <snibble-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I want to add some functionality to DateTime and stuff. I''m not sure > how I would go about extending it though...would I modify the class > itself in the core, extend it in another class, etc? Also, I don''t see > where I''d put it in my rails application....thanks! > > >-- Ryan Bigg --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ryan''s right -- Ruby classes are always open for extension. As for where to put it in a Rails app... the ''lib'' folder is probably the most logical place if you''re working on code that is specific to your application. If it''s something that you''d like to share with the world (or possibly just some of your other projects) then build it into a plugin. On Dec 5, 7:45 pm, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Put it in the lib directory. It doesn''t matter what name you give it. > > Ruby classes are cool in regards to being able to add functionality. In > other languages, doing: > > class DateTime > #blah > end > > when there''s already a DateTime class defined might throw an error! > > Thankfully, Ruby understands that sometimes we want to add to something so > doing > > class DateTime > code > end > > Will add that code to the DateTime class. Out of interest, what code are you > adding to it? > > On Dec 6, 2007 11:12 AM, Mike C <snib...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > I want to add some functionality to DateTime and stuff. I''m not sure > > how I would go about extending it though...would I modify the class > > itself in the core, extend it in another class, etc? Also, I don''t see > > where I''d put it in my rails application....thanks! > > -- > Ryan Bigg--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Interested to know the changes you like to make -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Basically he was attempting to override the Rails method sum. On Dec 7, 2007 4:24 PM, Ayyanar Aswathaman <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Interested to know the changes you like to make > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ryan Bigg http://www.frozenplague.net --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---