Deniz
2006-Jan-30 16:56 UTC
[Rails] error when adding a new table to the existing application
Deniz wrote:> Hi Everybody, > I am a newbie in this list so please forgive me if this is a lengthy > message. > Currently I am working on a project at my work place that includes > viewing some oracle tables(I do not have control over to rewrite the > tables) and searching the tables based on a given criteria with Rails. > Up untill now everything was working great. The database consists of a > lot of tables but I was working with five of them. Then I realized > that one of the fields in a table was referring to another table in > the database. For example if I had a DN (Directory Number) in the > table, that three digit DN was referring to another table being an > actual DN. So I decided to add that table. The actual name of the > table is cfg_dn (Legacy) with the following assignments I created the > model/controller and view > > */ruby script/generate scaffold cfg_dn cfg_dn > > /*Again, up untill now everything that I wanted to do with the > database was working properly. I went ahead and typed the following to > my browser to see if I am hitting the table. > > /*http://localhost:3000/cfg_dn*/ > > To my amazement the error I got: > > > NoMethodError in Cfg_dn#index > >undefined method `empty?'' for 3:Fixnum > > |RAILS_ROOT: ./script/../config/..| > > Application Trace <http://localhost:3000/cfg_dn#> | Framework Trace > <http://localhost:3000/cfg_dn#> | Full Trace > <http://localhost:3000/cfg_dn#> > >|c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:890:in `instantiate_without_callbacks'' >c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/callbacks.rb:215:in `instantiate'' >c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:431:in `find_by_sql'' >c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:431:in `collect!'' >c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:431:in `find_by_sql'' >c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:395:in `find'' >c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:174:in `find_collection_for_pagination'' >c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:192:in `paginator_and_collection_for'' >c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:124:in `paginate'' >#{RAILS_ROOT}/app/controllers/cfg_dn_controller.rb:8:in `list'' >#{RAILS_ROOT}/app/controllers/cfg_dn_controller.rb:3:in `index''| > >|c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:890:in `instantiate_without_callbacks'' >c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/callbacks.rb:215:in `instantiate'' >c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:431:in `find_by_sql'' >c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:431:in `collect!'' >c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:431:in `find_by_sql'' >c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:395:in `find'' >c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:174:in `find_collection_for_pagination'' >c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:192:in `paginator_and_collection_for'' >c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:124:in `paginate'' >c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:853:in `send'' >c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:853:in `perform_action_without_filters'' >c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/filters.rb:332:in `perform_action_without_benchmark'' >c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'' >c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:in `measure'' >c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'' >c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/rescue.rb:82:in `perform_action'' >c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:369:in `send'' >c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:369:in `process_without_session_management_support'' >c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/session_management.rb:116:in `process'' >c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/dispatcher.rb:38:in `dispatch'' >c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:117:in `handle_dispatch'' >c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:83:in `service'' >c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'' >c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'' >c:/ruby/lib/ruby/1.8/webrick/server.rb:155:in `start_thread'' >c:/ruby/lib/ruby/1.8/webrick/server.rb:144:in `start'' >c:/ruby/lib/ruby/1.8/webrick/server.rb:144:in `start_thread'' >c:/ruby/lib/ruby/1.8/webrick/server.rb:94:in `start'' >c:/ruby/lib/ruby/1.8/webrick/server.rb:89:in `each'' >c:/ruby/lib/ruby/1.8/webrick/server.rb:89:in `start'' >c:/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start'' >c:/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start'' >c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:69:in `dispatch'' >c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/servers/webrick.rb:59 >c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require__'' >c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require'' >c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in `require'' >c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/server.rb:28 >c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require__'' >c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require'' >c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in `require'' >script/server:5| > >|c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:890:in `instantiate_without_callbacks'' >c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/callbacks.rb:215:in `instantiate'' >c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:431:in `find_by_sql'' >c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:431:in `collect!'' >c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:431:in `find_by_sql'' >c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:395:in `find'' >c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:174:in `find_collection_for_pagination'' >c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:192:in `paginator_and_collection_for'' >c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:124:in `paginate'' >#{RAILS_ROOT}/app/controllers/cfg_dn_controller.rb:8:in `list'' >#{RAILS_ROOT}/app/controllers/cfg_dn_controller.rb:3:in `index'' >c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:853:in `send'' >c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:853:in `perform_action_without_filters'' >c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/filters.rb:332:in `perform_action_without_benchmark'' >c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'' >c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:in `measure'' >c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'' >c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/rescue.rb:82:in `perform_action'' >c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:369:in `send'' >c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:369:in `process_without_session_management_support'' >c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/session_management.rb:116:in `process'' >c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/dispatcher.rb:38:in `dispatch'' >c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:117:in `handle_dispatch'' >c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:83:in `service'' >c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'' >c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'' >c:/ruby/lib/ruby/1.8/webrick/server.rb:155:in `start_thread'' >c:/ruby/lib/ruby/1.8/webrick/server.rb:144:in `start'' >c:/ruby/lib/ruby/1.8/webrick/server.rb:144:in `start_thread'' >c:/ruby/lib/ruby/1.8/webrick/server.rb:94:in `start'' >c:/ruby/lib/ruby/1.8/webrick/server.rb:89:in `each'' >c:/ruby/lib/ruby/1.8/webrick/server.rb:89:in `start'' >c:/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start'' >c:/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start'' >c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:69:in `dispatch'' >c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/servers/webrick.rb:59 >c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require__'' >c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require'' >c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in `require'' >c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/server.rb:28 >c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require__'' >c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require'' >c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in `require'' >script/server:5| > > > Request > > *Parameters*: None > > Show session dump <http://localhost:3000/cfg_dn#> > >--- >flash: !ruby/hash:ActionController::Flash::FlashHash {} > > > Response > > *Headers*: {"cookie"=>[], "Cache-Control"=>"no-cache"} > > Also please note that when i do the same thing for the previous five > tables, it works. It is just this table that I am having problem with. > And another thing is that I am able to see this table using Brio > Software (This software allows you to put together tables and do some > queries on it). So the table is definetely there and the contents are > definetely there. > I do not know what this error means and I do not know how to fix it. > Could any one give me some suggestions? > I would be more than happy to give more information if necessary. > Thanks a lot > Deniz Rende. > >------------------------------------------------------------------------ > >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/rails > >Could anybody give me more suggestions on this problem please? I''ve been constantly trying to figure out for almost 2 weeks. Please let me know if you guys need more feedback... Thank you very much Dnz... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060130/03ec09be/attachment.html
Alex Young
2006-Jan-30 17:09 UTC
[Rails] error when adding a new table to the existing application
Deniz wrote:> Deniz wrote: >> Hi Everybody, >> I am a newbie in this list so please forgive me if this is a lengthy >> message.<snip> What''s the schema? -- Alex
Deniz
2006-Jan-30 17:12 UTC
[Rails] error when adding a new table to the existing application
Alex Young wrote:> Deniz wrote: > >> Deniz wrote: >> >>> Hi Everybody, >>> I am a newbie in this list so please forgive me if this is a lengthy >>> message. >> > <snip> > > What''s the schema? >It connects to a remote oracle database through vpn..
Alex Young
2006-Jan-30 17:19 UTC
[Rails] error when adding a new table to the existing application
Deniz wrote:> Alex Young wrote: >> <snip> >> >> What''s the schema? >> > It connects to a remote oracle database through vpn..Right. So what''s the schema? What''s the table definition for cfg_dn? -- Alex
Deniz
2006-Jan-30 17:37 UTC
[Rails] error when adding a new table to the existing application
Alex Young wrote:> Deniz wrote: > >> Alex Young wrote: >> >>> <snip> >>> >>> What''s the schema? >>> >> It connects to a remote oracle database through vpn.. > > Right. So what''s the schema? What''s the table definition for cfg_dn? >Okey, Sorry about that, Below is the table def for cfg_dn DBID [DECIMAL(10,0), Required] SWITCH_DBID[DECIMAL(10,0), Nullable] TENANT_DBID[DECIMAL(10,0), Nullable] TYPE [DECIMAL(38,0), Nullable] NUMBER_ [VARCHAR2(255),Nullable] ASSOCIATION [VARCHAR2(255),Nullable] LOGIN_FLAG [DECIMAL(38,0),Nullable] DN_LOGIN_ID [VARCHAR2(255),Nullable] REGISTER_ALL [DECIMAL(38,0), Nullable] GROUP_DBID[DECIMAL(10,0), Nullable] TRUNKS [DECIMAL(10,0), Nullable] ROUTE_TYPE[DECIMAL(38,0), Nullable] OVERRIDE [VARCHAR2(255),Nullable] STATE [DECIMAL(38,0), Nullable] NAME [VARCHAR2(255),Nullable] USE-OVERRIDE[DECIMAL[38,0],Nullable] SW_SPECIFIC_TYPE [DECIMAL[38,0],Nullable] CSID [DECIMAL(10,0), Nullable] SWITCH_CSID [DECIMAL(10,0), Nullable] TENANT_CSID [DECIMAL(10,0), Nullable] GROUP_CSID[DECIMAL(10,0), Nullable] PLACE_DBID[DECIMAL(10,0), Nullable] PLACE_CSID[DECIMAL(10,0), Nullable] <End of List> As I mentioned before, I am not authorized to overide the tables. I obtained the list using MSQUERY32.exe Thanks.. Dnz
Alex Young
2006-Jan-30 20:49 UTC
[Rails] error when adding a new table to the existing application
Deniz wrote:> Alex Young wrote: > >> Deniz wrote: >> >>> Alex Young wrote: >>> >>>> <snip> >>>> >>>> What''s the schema? >>>> >>> It connects to a remote oracle database through vpn.. >> >> Right. So what''s the schema? What''s the table definition for cfg_dn? >>Got it. I think it''s your TYPE column. ActiveRecord uses `type` as an indicator for single table inheritance, and the code assumes the content''s going to be a string, which is why it''s calling a string method on it. Nasty little bug you''ve found there, and I can entirely see why it''s been confusing. It''s funny, though - the MySQL adapter distinguishes between `TYPE` and `type`, and gives a different error to the one you''ve sent when the lower-case value is used. I can only assume that the Oracle adapter for some reason allows that not to get caught... Try changing your app/models/cfg_dn.rb to look something like this: class CfgDn < ActiveRecord::Base def self.inheritance_column() ''dontcare'' end end I haven''t tested it, but the inheritance_column() method should tell it to look for a column named ''dontcare'' when determining whether or not to trigger single table inheritance. That column doesn''t exist, so the failing method shouldn''t get triggered. If it turns out not to be that, I reckon it''s got to be data-dependent. I would suggest trying out the scaffolding on an empty database with the same schema, and slowly add data in until you get it to fail... Hope this helps, -- Alex
Deniz
2006-Jan-30 22:57 UTC
[Rails] error when adding a new table to the existing application
Alex Young wrote:> Deniz wrote: > >> Alex Young wrote: >> >>> Deniz wrote: >>> >>>> Alex Young wrote: >>>> >>>>> <snip> >>>>> >>>>> What''s the schema? >>>>> >>>> It connects to a remote oracle database through vpn.. >>> >>> >>> Right. So what''s the schema? What''s the table definition for cfg_dn? >>> > Got it. I think it''s your TYPE column. ActiveRecord uses `type` as > an indicator for single table inheritance, and the code assumes the > content''s going to be a string, which is why it''s calling a string > method on it. Nasty little bug you''ve found there, and I can entirely > see why it''s been confusing. It''s funny, though - the MySQL adapter > distinguishes between `TYPE` and `type`, and gives a different error > to the one you''ve sent when the lower-case value is used. I can only > assume that the Oracle adapter for some reason allows that not to get > caught... > > Try changing your app/models/cfg_dn.rb to look something like this: > > class CfgDn < ActiveRecord::Base > def self.inheritance_column() > ''dontcare'' > end > end > > I haven''t tested it, but the inheritance_column() method should tell > it to look for a column named ''dontcare'' when determining whether or > not to trigger single table inheritance. That column doesn''t exist, > so the failing method shouldn''t get triggered. > > If it turns out not to be that, I reckon it''s got to be > data-dependent. I would suggest trying out the scaffolding on an > empty database with the same schema, and slowly add data in until you > get it to fail... > > Hope this helps,Alex, You are absolutely awsome. Thank you very much. It worked and I don''t know how and why. I looked at your explanation and I changed the model as you suggested. At first I put ''Number'' in the place of ''dontcare'' and as a result I got the following error: ActiveRecord::SubclassNotFound in Test#index The single-table inheritance mechanism failed to locate the subclass: ''Q410''. This error is raised because the column ''number_'' is reserved for storing the class in case of inheritance. Please rename this column if you didn''t intend it to be used for storing the inheritance class or overwrite CfgDn.inheritance_column to use another column for that information. |RAILS_ROOT: ./script/../config/..| Application Trace <http://localhost:3000/test#> | Framework Trace <http://localhost:3000/test#> | Full Trace <http://localhost:3000/test#> |c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:897:in `instantiate_without_callbacks'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/callbacks.rb:215:in `instantiate'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:431:in `find_by_sql'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:431:in `find_by_sql'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:395:in `find'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:174:in `find_collection_for_pagination'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:192:in `paginator_and_collection_for'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:124:in `paginate'' #{RAILS_ROOT}/app/controllers/test_controller.rb:8:in `list'' #{RAILS_ROOT}/app/controllers/test_controller.rb:3:in `index''| |c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:897:in `instantiate_without_callbacks'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/callbacks.rb:215:in `instantiate'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:431:in `find_by_sql'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:431:in `find_by_sql'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:395:in `find'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:174:in `find_collection_for_pagination'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:192:in `paginator_and_collection_for'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:124:in `paginate'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:853:in `perform_action_without_filters'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/filters.rb:332:in `perform_action_without_benchmark'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'' c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/rescue.rb:82:in `perform_action'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:369:in `process_without_session_management_support'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/session_management.rb:116:in `process'' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/dispatcher.rb:38:in `dispatch'' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:117:in `handle_dispatch'' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:83:in `service'' c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'' c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'' c:/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'' c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'' c:/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'' c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'' c:/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'' c:/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:69:in `dispatch'' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/servers/webrick.rb:59 c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in `require'' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/server.rb:28 c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in `require'' script/server:5| |c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:897:in `instantiate_without_callbacks'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/callbacks.rb:215:in `instantiate'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:431:in `find_by_sql'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:431:in `find_by_sql'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:395:in `find'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:174:in `find_collection_for_pagination'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:192:in `paginator_and_collection_for'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:124:in `paginate'' #{RAILS_ROOT}/app/controllers/test_controller.rb:8:in `list'' #{RAILS_ROOT}/app/controllers/test_controller.rb:3:in `index'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:853:in `perform_action_without_filters'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/filters.rb:332:in `perform_action_without_benchmark'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'' c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/rescue.rb:82:in `perform_action'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:369:in `process_without_session_management_support'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/session_management.rb:116:in `process'' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/dispatcher.rb:38:in `dispatch'' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:117:in `handle_dispatch'' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:83:in `service'' c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'' c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'' c:/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'' c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'' c:/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'' c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'' c:/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'' c:/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:69:in `dispatch'' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/servers/webrick.rb:59 c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in `require'' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/server.rb:28 c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in `require'' script/server:5| Request *Parameters*: None Show session dump <http://localhost:3000/test#> --- flash: !map:ActionController::Flash::FlashHash {} Response *Headers*: {"cookie"=>[], "Cache-Control"=>"no-cache"} So seeing the error, I changed back ''dontcare'' to ''dn_login_id'' and voila.... I actually did not try to add the new table to the existing application yet. I just created a new project to test out this. The next thing I am gonna do is to integrate this apprach to my app. And also how did you figure out this? I''ve been banging my head to the wall over two weeks now. Could you please explain a little more how this self.inheritence_colum() work? for example why do i need to have ''self'' in front of inheritence_column()? and How do I get more information about the methods like inheritence_column()? I greatly appreciate you help and again thank you. Dnz.... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060130/f15e26a2/attachment-0001.html
Scott
2006-Jan-30 22:58 UTC
[Rails] Re: error when adding a new table to the existing applicatio
Deniz, It sounds to me like a referential integrity issue. ie.. The table that you are trying to change has a foreign key with ON DELETE CASCADE and/or ON UPDATE CASCADE constraints. So when you attempt to change the table your working on the database throws an error saying in effect "You can''t do that because another table has a relationship to this me. Please change that one first." If you can, extract your entire db as a sql statment. Then look for something like: CONSTRAINT BOOK_SECT FOREIGN KEY (SECTION_ID) REFERENCES SECTION(SECTION_ID) ON DELETE CASCADE It looks as if it may be DN_LOGIN_ID. Is that a three digit entry? The foreign key may not be in the table your working on. Look for a foreign ke reference to a row in your current table from another table. Then again I could be totally off base. Crack being what it is and all. Scott. -- Posted via http://www.ruby-forum.com/.
Alex Young
2006-Jan-30 23:28 UTC
[Rails] error when adding a new table to the existing application
Deniz wrote:> Alex Young wrote:<snip>> So seeing the error, I changed back ''dontcare'' to ''dn_login_id'' and > voila.... > I actually did not try to add the new table to the existing application > yet. I just created a new project to test out this. The next thing I am > gonna do is to integrate this apprach to my app. > And also how did you figure out this?I thought I''d figured something out about data dependence (it had to be doing something weird and data-related to be calling empty? on something that clearly wasn''t internal to Rails), and then I spotted the first line of the trace you emailed: c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:890:in `instantiate_without_callbacks'' Lines 889 and 890 look like this: if subclass_name = record[inheritance_column] if subclass_name.empty? Once I saw inheritance_column in there, and with your schema info available, it clicked.> Could you please explain a little more how this > self.inheritence_colum() work?It''s a class method that returns a single string. That string is used (by a few other places in the code) to find the column which holds the class name data for ActiveRecord subclasses to be instantiated as. It''s documented clearer than I could probably explain it at http://api.rubyonrails.com/classes/ActiveRecord/Base.html.> for example why do i need to have ''self'' > in front of inheritence_column()?That''s because it''s a class method, rather than an instance method. Check here for more details: http://www.rubycentral.com/book/tut_classes.html Basically, it means that Rails doesn''t need an instance of the class before it can find the information it needs to correctly create instances. It''s a like a singleton method, if that terminology means anything to you.> and How do I get more information about the methods like > inheritence_column()?See http://api.rubyonrails.com. Oh, and the source code :-)> I greatly appreciate you help and again thank you.No worries :-) Oh, and a quick pointer, before you run into any more problems (although you may have spotted this already) - You''re going to need to call set_primary_key in CfgDn, because ActiveRecord won''t know which column is unique in that table. Check the docs for more info on that. -- Alex
Deniz
2006-Jan-31 00:01 UTC
[Rails] Re: error when adding a new table to the existing applicatio
Scott wrote:>Deniz, >It sounds to me like a referential integrity issue. ie.. The table that >you are trying to change has a foreign key with ON DELETE CASCADE and/or >ON UPDATE CASCADE constraints. So when you attempt to change the table >your working on the database throws an error saying in effect "You can''t >do that because another table has a relationship to this me. Please >change that one first." > >If you can, extract your entire db as a sql statment. Then look for >something like: > >CONSTRAINT BOOK_SECT FOREIGN KEY (SECTION_ID) REFERENCES >SECTION(SECTION_ID) ON DELETE CASCADE > >It looks as if it may be DN_LOGIN_ID. Is that a three digit entry? > >The foreign key may not be in the table your working on. Look for a >foreign ke reference to a row in your current table from another table. > >Then again I could be totally off base. Crack being what it is and all. > >Scott. > > > > >Scott, thank you for your reply. From what I saw, DN_LOGIN_ID is empty for this particular example. Actually DBID is three digit but what I am trying to do actually is to search the database with Number_. Number_ is the four digit actual DN I am looking for. The search was working with the DN 3 digit entry, now I am working on to do the same thing with Number_ Thanx. Deniz.