0

I'm developeing with Rails 2.3.8 Ruby 1.8.7 and PostgreSQL. I want to search records by relation.

UserGuildMaster

class UserGuildMaster < ActiveRecord::Base
    has_one :leader, :foreign_key => 'guild_id', :class_name => 'UserGuildLog', :conditions => {:leader_flag => 1, :status => 1}
    has_many :user_guild_logs, :foreign_key => 'guild_id', :class_name => 'UserGuildLog'
end

UserGuildLog

class UserGuildLog < ActiveRecord::Base
    belongs_to :guild, :class_name => "UserGuildMaster"
    belongs_to :user_master
    belongs_to :user_character, :class_name => "UserCharacter"
end

UserCharacter

class UserCharacter < ActiveRecord::Base
end

I want to search UserGuildMaster which leader.user_character.logined_at is before 5days and which has less than 10 user_guild_logs.

My find conditions is below, but it raise error 'PGError: ERROR: schema "leader"'does not exist.

  @user_guild_masters = UserGuildMaster.find(:all, :include => [{:leader => :user_character}, :user_guild_logs], 
    :conditions => ['leader.user_character.logined_at < ? AND user_guild_logs.size < ?', 5.days.ago, 10]
  )

This Rails project is now on service and can't add or change column. I have no idea to finde these related records. Any ideas?

Chris Travers
  • 25,424
  • 6
  • 65
  • 182
DIGITALSQUAD
  • 3,384
  • 3
  • 22
  • 24
  • 1
    The error says it all, really. You don't have a schema called "leader" defined. Possible causes include: You're not running against the database you think you are; your schema is called `"Leader"` or `"LEADER"` not `leader` (see `\dn` in `psql`); you're trying to use the `schemaname.tablename.columname` syntax as if it were some kind of implicit join path expression like the (wrong) `tablename1.tablename2.columnname`. – Craig Ringer Aug 22 '12 at 03:55
  • Thanks for your comment. Actually I guess the problem is that the relation name and table name is not match. I'll check more in a few days. – DIGITALSQUAD Aug 23 '12 at 01:21

0 Answers0