Model inheritance is borken in Rails1.1


#1

following is model code in file order_payment.rb
class OrderPayment < ActiveRecord::Base
belongs_to :order
validates_presence_of :amount, :no
end

class LC < OrderPayment
end

class LC30 < LC
end

class LC60 < LC
end

class LC90 < LC
end

class LC120 < LC
end

class TT < OrderPayment

end

class CAD < OrderPayment

end
and following is error i’m getting with rails1.1.0 above code is working
fine with rails1.0.0
NameError in Order#add_payment

uninitialized constant LC

RAILS_ROOT: script/…/config/…
Application Trace
http://0.0.0.0:3000/order/add_payment?order_id=44# | Framework
Trace http://0.0.0.0:3000/order/add_payment?order_id=44# | Full
Tracehttp://0.0.0.0:3000/order/add_payment?order_id=44#

/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.0/lib/active_support/dependencies.rb:112:in
const_missing' /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.0/lib/active_support/dependencies.rb:120:inconst_missing’

/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.0/lib/active_support/dependencies.rb:122:in
const_missing' #{RAILS_ROOT}/app/controllers/order_controller.rb:61:inadd_payment’

/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.0/lib/active_support/dependencies.rb:112:in
const_missing' /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.0/lib/active_support/dependencies.rb:120:inconst_missing’
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.0/lib/active_support/dependencies.rb:122:in
const_missing' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/base.rb:908:inperform_action_without_filters’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/filters.rb:355:in
perform_action_without_benchmark' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/benchmarking.rb:69:inperform_action_without_rescue’
/usr/lib/ruby/1.8/benchmark.rb:293:in measure' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/benchmarking.rb:69:inperform_action_without_rescue’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/rescue.rb:82:in
perform_action' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/base.rb:379:inprocess_without_filters’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/filters.rb:364:in
process_without_session_management_support' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/session_management.rb:117:inprocess’
/usr/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/dispatcher.rb:38:in
dispatch' /usr/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/webrick_server.rb:115:inhandle_dispatch’
/usr/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/webrick_server.rb:81:in
service' /usr/lib/ruby/1.8/webrick/httpserver.rb:104:inservice’
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in run' /usr/lib/ruby/1.8/webrick/server.rb:173:instart_thread’
/usr/lib/ruby/1.8/webrick/server.rb:162:in start_thread' /usr/lib/ruby/1.8/webrick/server.rb:95:instart’
/usr/lib/ruby/1.8/webrick/server.rb:92:in start' /usr/lib/ruby/1.8/webrick/server.rb:23:instart’
/usr/lib/ruby/1.8/webrick/server.rb:82:in start' /usr/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/webrick_server.rb:67:indispatch’
/usr/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/commands/servers/webrick.rb:59
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:21:in require' /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.0/lib/active_support/dependencies.rb:136:inrequire’
/usr/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/commands/server.rb:30
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:21:in require' /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.0/lib/active_support/dependencies.rb:136:inrequire’
./script/server:3

/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.0/lib/active_support/dependencies.rb:112:in
const_missing' /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.0/lib/active_support/dependencies.rb:120:inconst_missing’
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.0/lib/active_support/dependencies.rb:122:in
const_missing' #{RAILS_ROOT}/app/controllers/order_controller.rb:61:inadd_payment’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/base.rb:908:in
perform_action_without_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/filters.rb:355:inperform_action_without_benchmark’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/benchmarking.rb:69:in
perform_action_without_rescue' /usr/lib/ruby/1.8/benchmark.rb:293:inmeasure’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/benchmarking.rb:69:in
perform_action_without_rescue' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/rescue.rb:82:inperform_action’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/base.rb:379:in
process_without_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/filters.rb:364:inprocess_without_session_management_support’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/session_management.rb:117:in
process' /usr/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/dispatcher.rb:38:indispatch’
/usr/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/webrick_server.rb:115:in
handle_dispatch' /usr/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/webrick_server.rb:81:inservice’
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in service' /usr/lib/ruby/1.8/webrick/httpserver.rb:65:inrun’
/usr/lib/ruby/1.8/webrick/server.rb:173:in start_thread' /usr/lib/ruby/1.8/webrick/server.rb:162:instart_thread’
/usr/lib/ruby/1.8/webrick/server.rb:95:in start' /usr/lib/ruby/1.8/webrick/server.rb:92:instart’
/usr/lib/ruby/1.8/webrick/server.rb:23:in start' /usr/lib/ruby/1.8/webrick/server.rb:82:instart’
/usr/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/webrick_server.rb:67:in
dispatch' /usr/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/commands/servers/webrick.rb:59 /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:21:inrequire’
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.0/lib/active_support/dependencies.rb:136:in
require' /usr/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/commands/server.rb:30 /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:21:inrequire’
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.0/lib/active_support/dependencies.rb:136:in
`require’
./script/server:3

This error occured while loading the following files:
lc.rb

Request

Parameters: {“order_id”=>“44”, “commit”=>“add”,
“payment”=>{“no”=>“NON”,
“date”=>"", “expiry_date”=>"", “type”=>“LC”, “paid”=>“0”,
“ship_date”=>"",
“amount”=>“23”}}

Show session dump http://0.0.0.0:3000/order/add_payment?order_id=44#
Response Headers: {“cookie”=>[], “Cache-Control”=>“no-cache”}


#2

its a feature…not a bug…

http://dev.rubyonrails.org/ticket/4402

On Friday, March 31, 2006, at 2:04 AM, Nexus Neo wrote:

end
class TT < OrderPayment
uninitialized constant LC
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.0/lib/active_support/
const_missing' filters.rb:355:inperform_action’
/usr/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/webrick_server.rb:115:in
/usr/lib/ruby/1.8/webrick/server.rb:82:in start' dependencies.rb:136:in dependencies.rb:122:inperform_action_without_rescue’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in service' /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:21:inrequire’
This error occured while loading the following files:


Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails

Mikkel B.

www.strongside.dk - Football Portal(DK)
ting.minline.dk - Buy Old Stuff!(DK)


#3

Thanks it solved.

On 31 Mar 2006 10:46:02 -0000, Mikkel B. <
removed_email_address@domain.invalid> wrote:

validates_presence_of :amount, :no

class CAD < OrderPayment
http://0.0.0.0:3000/order/add_payment?order_id=44# | Framework
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.0/lib/active_support/
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.0/lib/active_support/
perform_action_without_rescue' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/service’
/usr/lib/ruby/gems/1.8/gems/rails-1.1.0
./script/server:3
#{RAILS_ROOT}/app/controllers/order_controller.rb:61:in add_payment' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/process_without_session_management_support’
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in run' /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:21:inrequire’
This error occured while loading the following files:
Show session dump http://0.0.0.0:3000/order/add_payment?order_id=44#
Mikkel B.
Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails


Best Regards,
Niket P.
For NexusNeo System
(A Div of NexusNeo System & Exim Pvt. Ltd)
Tel: +91 79 23244557
Fax: +91 79 23246531
E-mail: removed_email_address@domain.invalid
Web: www.nexusneo.com