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: <H2>Tests:</H2>
19: <pre>
20: <% a = @subproject.tests -%>
21: <%= a.class %>
22:
23: </pre>
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
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
One detail: The Object::3 output is actually a debug reference I added to expose modularized_name in the call. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I get the same sort of error if I replace show from planner_controller
with the following:
def show
@tests = AgTest.find(:all, :conditions => "subProjectID
''#{params[:id]}''")
STDERR.puts #{@tests.class}
end
So we can leave the viewer out of the discussion. We can probably
leave the association thing out as well.
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Student wrote:> C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1359: syntax error, unexpected tINTEGER You''re getting a syntax error out of activerecord? It sounds like you''ve accidentally broken the source. Try uninstalling the gem and reinstalling? -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I had not touched the source when this began. I checked the install,
it is clean.
The added line was a STDERR.puts which did not affect the block
output. As for the syntax error, it''s coming from a class_eval
statement...
# Returns the class type of the record using the current
module as a prefix. So descendents of
# MyApp::Business::Account would appear as
MyApp::Business::AccountSubclass.
def compute_type(type_name)
modularized_name = type_name_with_module(type_name)
begin
--> class_eval(modularized_name, __FILE__, __LINE__)
rescue NameError
class_eval(type_name, __FILE__, __LINE__)
end
end
I''ll unzip a fresh copy of InstaRails & see what happens...
On Sep 21, 2:55 pm, Matthew Rudy
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> Student wrote:
> > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
>
> active_record/base.rb:1359: syntax error, unexpected tINTEGER
>
> You''re getting a syntax error out of activerecord?
>
> It sounds like you''ve accidentally broken the source.
> Try uninstalling the gem
> and reinstalling?
>
> --
> Posted viahttp://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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Do you have a type column on one of these tables? I''m guessing you do and that it contains integers. When active record sees a column called type it assumes you are using single table inheritance and that the value of the type column is the name of the class for the row in question. 3 isn''t a valid class name hence the error. You can use set_inheritance_column to tell AR to use a different column 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Score. I just set the inheritance column to xxx and we''re looking good. On Sep 24, 9:10 am, Frederick Cheung <rails-mailing-l...@andreas- s.net> wrote:> Do you have a type column on one of these tables? I''m guessing you do > and that it contains integers. When active record sees a column called > type it assumes you are using single table inheritance and that the > value of the type column is the name of the class for the row in > question. 3 isn''t a valid class name hence the error. > > You can use set_inheritance_column to tell AR to use a different column > > Fred > -- > Posted viahttp://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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---