Just another question:
How about if I need to call out the name of the column as well as
the value
it shows if that column has the minimum value.
something like model.attributes.(except or slice or reject).sort {|
first, second| first[1] <=> second[1]}
This will return a sorted array of key value pairs.
Now that I am working on it the I don't know to call out the header
name of
the coloumn.
Btw I am looking through the ruby api but I just can't seem to find
this
info, where do u learn .attribute from??? Could u also send me the
link?
if you're looking through the ruby api you won't find it because you
need to be looking at the rails ones. There are quite a few places
which display the docs in a variety of formats, including http://api.rubyonrails.com/
Let me try to rephrase: where do u learn the how to manipulate the model
with those extensions. For instance (model. "attribute". "value") where do u
learn that u can add those values to the model so that u can bring something
like the attribute or the cell value of the record out I can't seem to find
any resource on it. The api gives methods but not this(or maybe I can't seem
to find where it is in the api)
[mailto:rubyonrails-talk@googlegroups.com] On Behalf Of Frederick Cheung
Let me try to rephrase: where do u learn the how to manipulate the
model
with those extensions. For instance (model. "attribute". "value")
where do u
learn that u can add those values to the model so that u can bring
something
like the attribute or the cell value of the record out I can't seem
to find
any resource on it. The api gives methods but not this(or maybe I
can't seem
to find where it is in the api)
if you have an instance of a model, some of the methods are part of
the api, but some are added at runtime based on information from the
database. So for example if your users table has a name column then
instances of User will have a name method, but there is nowhere you
can look that up. There are a few other places where rails generates
methods at run time (eg dynamic finders).