Still working this global legacy database. I’m autogenerating the
base model files.
Here’s the error:
ActionView::TemplateError (compile error
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/base.rb:1359: syntax error, unexpected tINTEGER
Object::3
^) on line #21 of app/views/planner/show.rhtml:
18:
Tests:
19:
20: <% a = @subproject.tests -%>
21: <%= a.class %>
22:
23:
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/base.rb:1358:in compute_type' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/base.rb:1066:in
instantiate_without_callbacks’
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/callbacks.rb:204:in instantiate' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/base.rb:427:in
find_by_sql’
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/base.rb:427:in collect!' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/base.rb:427:in
find_by_sql’
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/base.rb:997:in find_every' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/base.rb:418:in
find’
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/associations/has_many_association.rb:91:in find' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/associations/association_collection.rb:159:in
find_target’
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/associations/has_many_association.rb:123:in
load_target' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/associations/association_proxy.rb:122:in
method_missing’
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/associations/has_many_association.rb:98:in
method_missing' #{RAILS_ROOT}/app/views/planner/show.rhtml:21:in
_run_rhtml_47app47views47planner47show46rhtml’
Relevant file snippets:
app/controllers/planner_controller.rb:
class PlannerController < ApplicationController
session :session_key => ‘_capacity_planner_id’
SQL_SELECT_FROM_BASE = “SELECT
rt.valueStr AS region,
p.Name AS projectName,
at.valueStr AS area,
sp.*
FROM
dbo.projectAttr AS at
INNER JOIN
dbo.project AS p ON at.projectId = p.projectId
INNER JOIN
dbo.subProject AS sp ON p.projectId = sp.projectId
INNER JOIN
dbo.subProjectAttr AS rt ON sp.subProjectId = rt.subProjectId
WHERE
(at.attributeId = ‘{F5AF5E6C-380C-499D-83ED-FA4BA6AD4D6B}’) AND
(rt.attributeId = ‘{1E9A75EA-BBD4-479E-A1B3-1CA30D891371}’)”
def show
@subproject = AgSubProject.find_by_sql(SQL_SELECT_FROM_BASE + “AND
(sp.subProjectId = ‘#{params[:id]}’)”)[0]
end
end
models/ag_sub_project.rb:
class AgSubProject < ActiveRecord::Base
set_table_name “subProject”
set_primary_key “subProjectId”
has_many :folders, :class_name =>
“AgFolder”, :foreign_key => “subProjectId”
belongs_to :entityStatus, :class_name =>
“AgEntityStatu”, :foreign_key => :entityStatusId
belongs_to :project, :class_name =>
“AgProject”, :foreign_key => :projectId
has_many :subProjectAttrs, :class_name =>
“AgSubProjectAttr”, :foreign_key => “subProjectId”
has_many :subProjectInvGroups, :class_name =>
“AgSubProjectInvGroup”, :foreign_key => “subProjectId”
has_many :subProjectInvModels, :class_name =>
“AgSubProjectInvModel”, :foreign_key => “subProjectId”
has_many :tests, :class_name =>
“AgTest”, :foreign_key => “subProjectId”
def after_create
self[:subProjectId] = new_guid
end
has_and_belongs_to_many(:db_attributes, :join_table =>
“subProjectAttr”,
:class_name => “AgAttribute”, :foreign_key => :subProjectId,
:association_foreign_key => :attributeId)
end
models/ag_test.rb:
class AgTest < ActiveRecord::Base
set_table_name “test”
set_primary_key “testId”
belongs_to :subProject, :class_name =>
“AgSubProject”, :foreign_key => :subProjectId
def after_create
self[:testId] = new_guid
end
end
====
The error message is the first interesting thing in the log file. In
an effort to narrow the problem, I’ve commented out all of the
associations for ag_test except the one listed.
Note that I can gather @subproject.tests, but I cannot even take the
class of the resultant object. The error Object::3 has also been seen
with Object::1.
???
Thanks,
Student