Forum: Ruby on Rails RE: Newbie Question about Custom Classes

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Hogan, Brian P. (Guest)
on 2006-03-20 17:53
(Received via mailing list)
If you've not read the Agile Web D. book, you really should.

YOu can define custom classes anywhere, really... *lib, vendor, etc.
However, what you have is definitely a model class... So create it in
the models folder.

App/models/article.rb

 class Article

    # class methods
    def self.find()
      # load a new article instance from the xml file based on the
conditions in the finder.
      # maybe you have to return an array of these article objects
because you might find
      # more than one.
    end

    def self.find_by_title

    end



    # instance methods
    def title
      ' return title
    end
    ...

 End

Then you can access it like any other model.

Please share what you create... It could be useful to others! Good luck!

Brian H.
Web D.
Learning & Technology Services
Schofield 3-B
University of Wisconsin-Eau Claire
715 836 3585
removed_email_address@domain.invalid
This topic is locked and can not be replied to.