RE: Newbie Question about Custom Classes


#1

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