You need to learn about ActiveRecord. This is too large a subject for a
quick answer on a forum.
Start with Rails tutorials. Take the time to understand how they are
using ActiveRecord, how the models relate to database tables and how the
#find method works for extracting data, including uses of #has_many,
#belongs_to and #has_one for linking models and use of :includes in the
#find method for doing implicit joins on tables.
Search for information about ActiveRecord to take you further. It
sounds like you are trying to fit Rails to an existing database schema,
so google for "rails activerecord legacy schema" and you should get a
few sites with advice on ways to access existing schemas from rails.
The ActiveRecord reference is available starting here:
http://api.rubyonrails.com/classes/ActiveRecord/Base.html
however this is a reference and probably will only be useful as such
alongside tutorials and other material.
--
Posted via http://www.ruby-forum.com/.