ruby / rails newbie - Finding documentation in RDocs

S

steveH

Hi, I'm brand new to ruby, to which I've been attracted by rails (along
with many others, no doubt). I'm trying to hack together my first rxml
template, but my first dip into the rdocs is a total failure. I see
code like this...

<% for column in Product.content_columns %>
<th><%= column.human_name %></th>
<% end %>

but I can't find a description of class Column anywhere - can't see it
in rails docs, core ruby docs, MySQL/Ruby docs - have I just missed it
or is it somewhere else, or isn't it a class at all but some sort of
dynamic ruby magic which I've totally misunderstood...

thanks for any help
 
J

James Britt

steveH said:
Hi, I'm brand new to ruby, to which I've been attracted by rails (along
with many others, no doubt). I'm trying to hack together my first rxml
template, but my first dip into the rdocs is a total failure. I see
code like this...

<% for column in Product.content_columns %>
<th><%= column.human_name %></th>
<% end %>

but I can't find a description of class Column anywhere - can't see it
in rails docs, core ruby docs, MySQL/Ruby docs - have I just missed it
or is it somewhere else, or isn't it a class at all but some sort of
dynamic ruby magic which I've totally misunderstood...

In the construct

for x in some.collection
...
end

x is a variable that takes on the file of each successive item in
collection.

See

http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_containers.html

and, in general,

http://www.ruby-doc.org/docs/ProgrammingRuby/
http://www.ruby-doc.org/gettingstarted/


James


--

http://www.ruby-doc.org - The Ruby Documentation Site
http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com - Playing with Better Toys
 
D

Dave Burt

James Britt offered:
steveH said:
<% for column in Product.content_columns %>
<th><%= column.human_name %></th>
<% end %>

but I can't find a description of class Column anywhere - can't see it
in rails docs, core ruby docs, MySQL/Ruby docs - have I just missed it
or is it somewhere else, or isn't it a class at all but some sort of
dynamic ruby magic which I've totally misunderstood...

In the construct

for x in some.collection
...
end

x is a variable that takes on the file of each successive item in
collection.

See [...]

James is right, there is no explicit type or class set for column, or indeed
any Ruby variable. All Ruby variables have the dynamic ruby magic property
of being able to hold an object of any type.

Here's some trivia realted to your question, though. For most or all of the
connection adapters, content_columns will return an Array of Column, a.k.a.
ActiveRecord::ConnectionAdapters::Column, which is a class in Rails, but
doesn't appear in the API docs. It has properties: name, default, type and
limit. You can read the source code for ConnectionAdapters, the
AbstractAdapter, and the adapter for your database if you want to know more.

Cheers,
Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top