Hello to all, I ran into a weird problem with an ActivRecord. I have a table named "build_order" with a column named "type" that is a foreign key to a table called "building_type". In a controller I try to read all the build_orders with "BuildOrder.find :all" and get the following error and stack trace: (eval):1:in `instance_eval'': compile error (eval):1: syntax error Object::0 ^ c:/programme/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:1244:in `instance_eval'' c:/programme/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:1244:in `instance_eval'' c:/programme/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:1244:in `compute_type'' c:/programme/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:983:in `instantiate_without_callbacks'' c:/programme/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/callbacks.rb:215:in `instantiate'' c:/programme/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:390:in `find_by_sql'' c:/programme/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:390:in `collect!'' c:/programme/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:390:in `find_by_sql'' c:/programme/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:924:in `find_every'' c:/programme/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:381:in `find'' #{RAILS_ROOT}/app/controllers/building_controller.rb:14:in `index'' If I replace the "find :all" with an "find_sql" where I read all the columns except the "type" column, the error doesn''t occur. The type of the column is "type INTEGER UNSIGNED NOT NULL". Is there anyone who have an idea what I might making wrong here? Thanks in advance and best regards Torsten
Hello to all, I ran into a weird problem with an ActivRecord. I have a table named "build_order" with a column named "type" that is a foreign key to a table called "building_type". In a controller I try to read all the build_orders with "BuildOrder.find :all" and get the following error and stack trace: (eval):1:in `instance_eval'': compile error (eval):1: syntax error Object::0 ^ c:/programme/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:1244:in `instance_eval'' c:/programme/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:1244:in `instance_eval'' c:/programme/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:1244:in `compute_type'' c:/programme/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:983:in `instantiate_without_callbacks'' c:/programme/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/callbacks.rb:215:in `instantiate'' c:/programme/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:390:in `find_by_sql'' c:/programme/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:390:in `collect!'' c:/programme/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:390:in `find_by_sql'' c:/programme/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:924:in `find_every'' c:/programme/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:381:in `find'' #{RAILS_ROOT}/app/controllers/building_controller.rb:14:in `index'' If I replace the "find :all" with an "find_sql" where I read all the columns except the "type" column, the error doesn''t occur. The type of the column is "type INTEGER UNSIGNED NOT NULL". Is there anyone who have an idea what I might making wrong here? Thanks in advance and best regards Torsten
> -----Original Message----- > From: rails-bounces@lists.rubyonrails.org > [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of > Torsten Robitzki > Sent: Tuesday, June 27, 2006 8:21 AM > To: rails@lists.rubyonrails.org > Subject: [Rails] Weird ActiveRecord Foreign Key Problem > > > Hello to all, > I ran into a weird problem with an ActivRecord. I have a table named > "build_order" with a column named "type" that is a foreign key to a > table called "building_type". In a controller I try to read all the > build_orders with "BuildOrder.find :all" and get the > following error and > stack trace: > > (eval):1:in `instance_eval'': compile error > (eval):1: syntax error > Object::0 > ^ > c:/programme/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/l > ib/active_record/base.rb:1244:in > `instance_eval'' > c:/programme/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/l > ib/active_record/base.rb:1244:in > `instance_eval'' > c:/programme/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/l > ib/active_record/base.rb:1244:in > `compute_type'' > c:/programme/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/l > ib/active_record/base.rb:983:in > `instantiate_without_callbacks'' > c:/programme/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/callbacks.rb:215:in> `instantiate'' > c:/programme/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/l > ib/active_record/base.rb:390:in > `find_by_sql'' > c:/programme/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/l > ib/active_record/base.rb:390:in > `collect!'' > c:/programme/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/l > ib/active_record/base.rb:390:in > `find_by_sql'' > c:/programme/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/l > ib/active_record/base.rb:924:in > `find_every'' > c:/programme/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/l > ib/active_record/base.rb:381:in > `find'' > #{RAILS_ROOT}/app/controllers/building_controller.rb:14:in `index'' > > If I replace the "find :all" with an "find_sql" where I read all the > columns except the "type" column, the error doesn''t occur. > The type of > the column is "type INTEGER UNSIGNED NOT NULL". Is there > anyone who have > an idea what I might making wrong here? > > Thanks in advance and best regards > TorstenIf I had to guess, I''d say that it''s a problem with the word "type", which is a keyword in Ruby. I''m not sure what the workaround is. Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments.
Berger, Daniel wrote:> If I had to guess, I''d say that it''s a problem with the word "type", > which is a keyword in Ruby.I have an othere table with a column name "type" an there it works. I changed it to "class" and it was still working. Then I changed the column "type" from the table where it wasn''t workin to "building_type". Now it''s working but I realy don''t like if I don''t know why it is not work or why it was not working, maybe there is still an uncovered bug. Thanks and best regards Torsten