Colin, Fred,
Thank you.

Colin,
it is not a typo, as I am learning ruby+rails I read that rails is 
expecting
the plural of the name of the table. I went nuts changing the names of 
the
tables. At the time I did not know that I could force the names, on top 
of this
this Spanish language influenced the person who designed the DB and 
rails is English oriented ;-)
I believe that inside :select you need the name of the table, and the 
symbol of the association is not allowed. Of course, I maybe wrong but I 
have not yet seen a sample code that lead me to think otherwise.

class Estado < ActiveRecord::Base
  has_many  :masters
end

class Master < ActiveRecord::Base
  belongs_to :estado
  belongs_to :municipio
  belongs_to :localidade
  has_one :migrante1
  has_one :migrante2
  has_one :migrante3
  has_one :migrante4
 ##
 ##named_scope
 ##
  named_scope :masculino, :conditions => {:sexo=>'masculino'}
  named_scope :femenino,  :conditions => {:sexo=>'femenino'}
## Test
  named_scope :edo, :joins=>:estado, :select=>"estados.estado"
end

Let me mention that this database is a legacy from one of the previous 
project/team (political scie...@tuffs University).

I did check the attributes, from the console:
>> ma=Master.edo
=> ma.first.attributes
=> {"estado"=>"Michoacan"}

This is progress, but what is the syntax to access it?
or this is it, and I have to treat it as a hash from this point on?




Although, not what I am looking for but related,
http://snippets.dzone.com/posts/show/2089

> The default output from inspect never shows columns from joined
> tables, but they are still there. (take a peak at the attributes for
> one of the objects returned in this manner)
> 
> Fred
-- 
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