Hi all,
I’m having problems with the following relationship, can anybody help
me out here? I’m using Rails 2.1. There is only i vote in the DB (and
the 2 users exist):
id voter_id voted_id type value status created_at
updated_at
2 15 17 0 APPROVED 0 2008-07-20 16:18:06 2008-07-20
16:18:06
Cheers, Sazima
Table name: votes
Field Type Null Default
id int(11) No auto_increment
voter_id int(11) No
voted_id int(11) No
type int(11) No 0
value varchar(255) Yes NULL
status int(11) Yes 0
created_at datetime Yes NULL
updated_at datetime Yes NULL
class Vote < ActiveRecord::Base
belongs_to :voter, :class_name => :user, :foreign_key => :voter_id
belongs_to :voted, :class_name => :user, :foreign_key => :voted_id
end
Table name: users
id :integer(11) not null, primary key
login :string(255)
crypted_password :string(40)
salt :string(40)
created_at :datetime
updated_at :datetime
class User < ActiveRecord::Base
Votes
has_many :votes_made, :class_name => :vote, :foreign_key
=> :voter_id
has_many :votes_received, :class_name => :vote, :foreign_key
=> :voted_id
has_many :votees, :through => :votes_made, :source => :user, :uniq
=> true
has_many :voters, :through => :votes_received, :source
=> :user, :uniq => true
end
THE ERROR I GET IS:
SyntaxError in VotesController#index
compile error
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/
lib/active_record/base.rb:1907: syntax error, unexpected tINTEGER
Object::0
^
RAILS_ROOT: C:/Personal/INSTAN~2/rails_apps/dateclub
Application Trace | Framework Trace | Full Trace
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/
lib/active_record/base.rb:1907:in compute_type' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/ lib/active_record/base.rb:1428:in
instantiate’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/
lib/active_record/base.rb:582:in find_by_sql' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/ lib/active_record/base.rb:582:in
collect!’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/
lib/active_record/base.rb:582:in find_by_sql' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/ lib/active_record/base.rb:1341:in
find_every’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/
lib/active_record/base.rb:536:in find_without_defaults' vendor/plugins/less_monkey_patching/lib/active_record_base.rb:13:in
find’
app/controllers/votes_controller.rb:46:in `index’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/
lib/active_record/base.rb:1907:in compute_type' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/ lib/active_record/base.rb:1428:in
instantiate’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/
lib/active_record/base.rb:582:in find_by_sql' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/ lib/active_record/base.rb:582:in
collect!’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/
lib/active_record/base.rb:582:in find_by_sql' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/ lib/active_record/base.rb:1341:in
find_every’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/
lib/active_record/base.rb:536:in find_without_defaults' vendor/plugins/less_monkey_patching/lib/active_record_base.rb:13:in
find’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/base.rb:1162:in send' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/base.rb:1162:in
perform_action_without_filters’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/filters.rb:580:in call_filters' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/filters.rb:573:in
perform_action_without_benchmark’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/benchmarking.rb:68:in
perform_action_without_rescue' C:/Personal/INSTAN~2/ruby/lib/ruby/1.8/benchmark.rb:293:in
measure’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/benchmarking.rb:68:in
perform_action_without_rescue' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/rescue.rb:201:in
perform_action_without_caching’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/caching/sql_cache.rb:13:in perform_action' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/ lib/active_record/connection_adapters/abstract/query_cache.rb:33:in
cache’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/
lib/active_record/query_cache.rb:8:in cache' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/caching/sql_cache.rb:12:in
perform_action’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/base.rb:529:in send' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/base.rb:529:in
process_without_filters’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/filters.rb:569:in
process_without_session_management_support' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/session_management.rb:130:in
process’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/base.rb:389:in process' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/dispatcher.rb:149:in
handle_request’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/dispatcher.rb:107:in dispatch' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/dispatcher.rb:104:in
synchronize’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/dispatcher.rb:104:in dispatch' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/dispatcher.rb:120:in
dispatch_cgi’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/dispatcher.rb:35:in dispatch' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86- mswin32-60/lib/mongrel/rails.rb:76:in
process’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86-
mswin32-60/lib/mongrel/rails.rb:74:in synchronize' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86- mswin32-60/lib/mongrel/rails.rb:74:in
process’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86-
mswin32-60/lib/mongrel.rb:159:in process_client' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86- mswin32-60/lib/mongrel.rb:158:in
each’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86-
mswin32-60/lib/mongrel.rb:158:in process_client' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86- mswin32-60/lib/mongrel.rb:285:in
run’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86-
mswin32-60/lib/mongrel.rb:285:in initialize' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86- mswin32-60/lib/mongrel.rb:285:in
new’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86-
mswin32-60/lib/mongrel.rb:285:in run' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86- mswin32-60/lib/mongrel.rb:268:in
initialize’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86-
mswin32-60/lib/mongrel.rb:268:in new' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86- mswin32-60/lib/mongrel.rb:268:in
run’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86-
mswin32-60/lib/mongrel/configurator.rb:282:in run' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86- mswin32-60/lib/mongrel/configurator.rb:281:in
each’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86-
mswin32-60/lib/mongrel/configurator.rb:281:in run' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86- mswin32-60/bin/mongrel_rails:128:in
run’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86-
mswin32-60/lib/mongrel/command.rb:212:in run' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86- mswin32-60/bin/mongrel_rails:281 C:/Personal/INSTAN~2/ruby/bin/mongrel_rails:19:in
load’
C:/Personal/INSTAN~2/ruby/bin/mongrel_rails:19
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/
lib/active_record/base.rb:1907:in compute_type' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/ lib/active_record/base.rb:1428:in
instantiate’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/
lib/active_record/base.rb:582:in find_by_sql' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/ lib/active_record/base.rb:582:in
collect!’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/
lib/active_record/base.rb:582:in find_by_sql' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/ lib/active_record/base.rb:1341:in
find_every’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/
lib/active_record/base.rb:536:in find_without_defaults' vendor/plugins/less_monkey_patching/lib/active_record_base.rb:13:in
find’
app/controllers/votes_controller.rb:46:in index' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/base.rb:1162:in
send’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/base.rb:1162:in perform_action_without_filters' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/filters.rb:580:in
call_filters’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/filters.rb:573:in perform_action_without_benchmark' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/benchmarking.rb:68:in
perform_action_without_rescue’
C:/Personal/INSTAN~2/ruby/lib/ruby/1.8/benchmark.rb:293:in measure' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/benchmarking.rb:68:in
perform_action_without_rescue’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/rescue.rb:201:in perform_action_without_caching' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/caching/sql_cache.rb:13:in
perform_action’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/
lib/active_record/connection_adapters/abstract/query_cache.rb:33:in
cache' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/ lib/active_record/query_cache.rb:8:in
cache’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/caching/sql_cache.rb:12:in perform_action' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/base.rb:529:in
send’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/base.rb:529:in process_without_filters' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/filters.rb:569:in
process_without_session_management_support’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/session_management.rb:130:in process' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/base.rb:389:in
process’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/dispatcher.rb:149:in handle_request' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/dispatcher.rb:107:in
dispatch’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/dispatcher.rb:104:in synchronize' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/dispatcher.rb:104:in
dispatch’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/dispatcher.rb:120:in dispatch_cgi' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/dispatcher.rb:35:in
dispatch’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86-
mswin32-60/lib/mongrel/rails.rb:76:in process' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86- mswin32-60/lib/mongrel/rails.rb:74:in
synchronize’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86-
mswin32-60/lib/mongrel/rails.rb:74:in process' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86- mswin32-60/lib/mongrel.rb:159:in
process_client’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86-
mswin32-60/lib/mongrel.rb:158:in each' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86- mswin32-60/lib/mongrel.rb:158:in
process_client’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86-
mswin32-60/lib/mongrel.rb:285:in run' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86- mswin32-60/lib/mongrel.rb:285:in
initialize’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86-
mswin32-60/lib/mongrel.rb:285:in new' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86- mswin32-60/lib/mongrel.rb:285:in
run’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86-
mswin32-60/lib/mongrel.rb:268:in initialize' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86- mswin32-60/lib/mongrel.rb:268:in
new’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86-
mswin32-60/lib/mongrel.rb:268:in run' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86- mswin32-60/lib/mongrel/configurator.rb:282:in
run’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86-
mswin32-60/lib/mongrel/configurator.rb:281:in each' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86- mswin32-60/lib/mongrel/configurator.rb:281:in
run’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86-
mswin32-60/bin/mongrel_rails:128:in run' C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86- mswin32-60/lib/mongrel/command.rb:212:in
run’
C:/Personal/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86-
mswin32-60/bin/mongrel_rails:281
C:/Personal/INSTAN~2/ruby/bin/mongrel_rails:19:in `load’
C:/Personal/INSTAN~2/ruby/bin/mongrel_rails:19
Request
Parameters:
None
Show session dump
:user: 15
:return_to: /
flash: !map:ActionController::Flash::FlashHash {}