Been developing in Rails for about a month and I'm still working on
grasping its subtleties.
Can someone please shed some light on this simple scenario?

## Schema ##

create_table :books do |t|
  t.string :title
  t.integer :year
end

create_table :pages do |t|
  t.integer :no
  t.references :book
end

## Models ##

Book has_many :pages
Page belongs_to :book


Then in Rails' console:

@pages = Page.all(
  :select => 'pages.id, pages.no, books.year book_year',
  :joins => :book
)

@pages.first.no.class #=> Fixnum
@pages.first.book_year.class #=> String


What I don't understand is why book_year is a String instead of a
Fixnum. Is it possible to get Book's columns correctly instantiated?

Thanks
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to