# A column named 'type'

**URL:** <https://www.ruby-forum.com/t/a-column-named-type/74741>\
**Category:** Rails\
**Created:** [November 7, 2006, 10:54am UTC](https://www.ruby-forum.com/t/a-column-named-type/74741 "2006-11-07T10:54:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ike](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/df705f/32.png) [@ike](https://www.ruby-forum.com/u/ike)\
**Post date:** [November 7, 2006, 10:54am UTC](https://www.ruby-forum.com/t/a-column-named-type/74741/1 "2006-11-07T10:54:45Z")

</div>

I have a column in my table ‘activities’ called ‘type’ such that  
activities.type=activitytypes.id. Having a column named ‘type,’ causes  
errors the workaround which is included in the following model files  
for these two models. I am using the scaffolding\_extensions plugin btw.

I can do anything on an activitytype (add, delete, edit…) However,  
when I go to do something, say, edit, an activity.I get the error  
listed below the models, below. Can anyone enlighten me as to what I am  
missing here to get past this error? (And yes, it’s a legacy db and I  
cannot alter the column or table names) -Ralph

class Activity \< ActiveRecord::Base

belongs\_to :activitytype, :foreign\_key =\> ‘type’

#add the following because I get the error:  
#This error is raised because the column ‘type’ 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 Activitytype.inheritance\_column to use another column for  
that information.

def self.inheritance\_column  
“rails\_type”  
end

end

class Activitytype \< ActiveRecord::Base

has\_many :activities, :foreign\_key =\> ‘type’

#add the following because I get the error:  
#The single-table inheritance mechanism failed to locate the  
subclass: ‘letter’. This error is raised because the column ‘type’ 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 Activitytype.inheritance\_column to use  
another column for that information.

def self.inheritance\_column  
“rails\_type”  
end

end

TypeError in Crud#edit\_activity

Showing vendor/plugins/scaffolding\_extensions/scaffolds/edit.rhtml  
where line #3 raised:

wrong argument type Fixnum (expected Module)

Extracted source (around line #3):

1:

# Editing \<%= @scaffold\_singular\_name.humanize.downcase %\>
  
2:  
3: \<%= scaffold\_form(‘update’,  
:fields=\>@scaffold\_class.scaffold\_edit\_fields) %\>  
4:  
5: \<%= association\_links %\>  
6:

RAILS\_ROOT: C:/INSTAN~2/rails\_apps/ggrip/config/…  
Application Trace | Framework Trace | Full Trace

C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_view/helpers/form\_options\_helper.rb:116:in  
`include?' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/helpers/form_options_helper.rb:116:in`options\_for\_select’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_view/helpers/form\_helper.rb:333:in  
`inject' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/helpers/form_options_helper.rb:114:in`each’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_view/helpers/form\_options\_helper.rb:114:in  
`inject' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/helpers/form_options_helper.rb:114:in`options\_for\_select’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_view/helpers/form\_options\_helper.rb:303:in  
`to_select_tag' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/helpers/form_options_helper.rb:66:in`select’  
#{RAILS\_ROOT}/vendor/plugins/scaffolding\_extensions/lib/scaffolding\_extensions.rb:411:in  
`association_select_tag' #{RAILS_ROOT}/vendor/plugins/scaffolding_extensions/lib/scaffolding_extensions.rb:391:in`default\_input\_block’  
#{RAILS\_ROOT}/vendor/plugins/scaffolding\_extensions/lib/scaffolding\_extensions.rb:378:in  
`call' #{RAILS_ROOT}/vendor/plugins/scaffolding_extensions/lib/scaffolding_extensions.rb:378:in`all\_input\_tags’  
#{RAILS\_ROOT}/vendor/plugins/scaffolding\_extensions/lib/scaffolding\_extensions.rb:375:in  
`collect' #{RAILS_ROOT}/vendor/plugins/scaffolding_extensions/lib/scaffolding_extensions.rb:375:in`all\_input\_tags’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_view/helpers/active\_record\_helper.rb:70:in  
`form' #{RAILS_ROOT}/vendor/plugins/scaffolding_extensions/lib/scaffolding_extensions.rb:528:in`scaffold\_form’  
#{RAILS\_ROOT}/vendor/plugins/scaffolding\_extensions/scaffolds/edit.rhtml:3:in  
`_run_rhtml_C__INSTAN1262_rails_apps_ggrip_vendor_plugins_scaffolding_extensions_scaffolds_edit' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:316:in`send’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_view/base.rb:316:in  
`compile_and_render_template' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:292:in`render\_template’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_view/base.rb:251:in  
`render_file' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:726:in`render\_file’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_controller/base.rb:661:in  
`render_with_no_layout' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/layout.rb:253:in`render\_without\_benchmark’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_controller/benchmarking.rb:53:in  
`render' C:/INSTAN~2/ruby/lib/ruby/1.8/benchmark.rb:293:in`measure’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_controller/benchmarking.rb:53:in  
`render' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:704:in`render\_to\_string’  
#{RAILS\_ROOT}/vendor/plugins/scaffolding\_extensions/lib/scaffolding\_extensions.rb:626:in  
`render_scaffold_template' #{RAILS_ROOT}/vendor/plugins/scaffolding_extensions/lib/scaffolding_extensions.rb:1104:in`render\_activity\_scaffold’  
#{RAILS\_ROOT}/vendor/plugins/scaffolding\_extensions/lib/scaffolding\_extensions.rb:975:in  
`edit_activity' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:941:in`send’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_controller/base.rb:941:in  
`perform_action_without_filters' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:368:in`perform\_action\_without\_benchmark’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_controller/benchmarking.rb:69:in  
`perform_action_without_rescue' C:/INSTAN~2/ruby/lib/ruby/1.8/benchmark.rb:293:in`measure’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_controller/benchmarking.rb:69:in  
`perform_action_without_rescue' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/rescue.rb:82:in`perform\_action’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_controller/base.rb:408:in  
`send' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:408:in`process\_without\_filters’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_controller/filters.rb:377:in  
`process_without_session_management_support' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/session_management.rb:117:in`process’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/dispatcher.rb:38:in  
`dispatch' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel/rails.rb:73:in`process’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:551:in  
`process_client' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:550:in`each’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:550:in  
`process_client' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:636:in`run’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:636:in  
`initialize' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:636:in`new’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:636:in  
`run' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:625:in`initialize’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:625:in  
`new' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:625:in`run’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:956:in  
`run' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:955:in`each’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:955:in  
`run' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/bin/mongrel_rails:127:in`run’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel/command.rb:199:in  
`run' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/bin/mongrel_rails:235 C:/INSTAN~2/ruby/bin/mongrel_rails:18:in`load’  
C:/INSTAN~2/ruby/bin/mongrel\_rails:18

C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_view/helpers/form\_options\_helper.rb:116:in  
`include?' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/helpers/form_options_helper.rb:116:in`options\_for\_select’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_view/helpers/form\_helper.rb:333:in  
`inject' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/helpers/form_options_helper.rb:114:in`each’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_view/helpers/form\_options\_helper.rb:114:in  
`inject' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/helpers/form_options_helper.rb:114:in`options\_for\_select’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_view/helpers/form\_options\_helper.rb:303:in  
`to_select_tag' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/helpers/form_options_helper.rb:66:in`select’  
#{RAILS\_ROOT}/vendor/plugins/scaffolding\_extensions/lib/scaffolding\_extensions.rb:411:in  
`association_select_tag' #{RAILS_ROOT}/vendor/plugins/scaffolding_extensions/lib/scaffolding_extensions.rb:391:in`default\_input\_block’  
#{RAILS\_ROOT}/vendor/plugins/scaffolding\_extensions/lib/scaffolding\_extensions.rb:378:in  
`call' #{RAILS_ROOT}/vendor/plugins/scaffolding_extensions/lib/scaffolding_extensions.rb:378:in`all\_input\_tags’  
#{RAILS\_ROOT}/vendor/plugins/scaffolding\_extensions/lib/scaffolding\_extensions.rb:375:in  
`collect' #{RAILS_ROOT}/vendor/plugins/scaffolding_extensions/lib/scaffolding_extensions.rb:375:in`all\_input\_tags’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_view/helpers/active\_record\_helper.rb:70:in  
`form' #{RAILS_ROOT}/vendor/plugins/scaffolding_extensions/lib/scaffolding_extensions.rb:528:in`scaffold\_form’  
#{RAILS\_ROOT}/vendor/plugins/scaffolding\_extensions/scaffolds/edit.rhtml:3:in  
`_run_rhtml_C__INSTAN1262_rails_apps_ggrip_vendor_plugins_scaffolding_extensions_scaffolds_edit' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:316:in`send’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_view/base.rb:316:in  
`compile_and_render_template' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:292:in`render\_template’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_view/base.rb:251:in  
`render_file' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:726:in`render\_file’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_controller/base.rb:661:in  
`render_with_no_layout' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/layout.rb:253:in`render\_without\_benchmark’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_controller/benchmarking.rb:53:in  
`render' C:/INSTAN~2/ruby/lib/ruby/1.8/benchmark.rb:293:in`measure’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_controller/benchmarking.rb:53:in  
`render' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:704:in`render\_to\_string’  
#{RAILS\_ROOT}/vendor/plugins/scaffolding\_extensions/lib/scaffolding\_extensions.rb:626:in  
`render_scaffold_template' #{RAILS_ROOT}/vendor/plugins/scaffolding_extensions/lib/scaffolding_extensions.rb:1104:in`render\_activity\_scaffold’  
#{RAILS\_ROOT}/vendor/plugins/scaffolding\_extensions/lib/scaffolding\_extensions.rb:975:in  
`edit_activity' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:941:in`send’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_controller/base.rb:941:in  
`perform_action_without_filters' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:368:in`perform\_action\_without\_benchmark’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_controller/benchmarking.rb:69:in  
`perform_action_without_rescue' C:/INSTAN~2/ruby/lib/ruby/1.8/benchmark.rb:293:in`measure’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_controller/benchmarking.rb:69:in  
`perform_action_without_rescue' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/rescue.rb:82:in`perform\_action’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_controller/base.rb:408:in  
`send' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:408:in`process\_without\_filters’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_controller/filters.rb:377:in  
`process_without_session_management_support' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/session_management.rb:117:in`process’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/dispatcher.rb:38:in  
`dispatch' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel/rails.rb:73:in`process’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:551:in  
`process_client' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:550:in`each’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:550:in  
`process_client' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:636:in`run’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:636:in  
`initialize' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:636:in`new’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:636:in  
`run' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:625:in`initialize’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:625:in  
`new' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:625:in`run’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:956:in  
`run' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:955:in`each’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:955:in  
`run' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/bin/mongrel_rails:127:in`run’  
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel/command.rb:199:in  
`run' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/bin/mongrel_rails:235 C:/INSTAN~2/ruby/bin/mongrel_rails:18:in`load’  
C:/INSTAN~2/ruby/bin/mongrel\_rails:18

Request

Parameters: {“id”=\>“1”}

Show session dump

* * *

flash: !map:ActionController::Flash::FlashHash {}

Response  
Headers: {“cookie”=\>[], “Cache-Control”=\>“no-cache”}

---

<div class="post-metadata">

**Author:** ![ike](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/df705f/32.png) [@ike](https://www.ruby-forum.com/u/ike)\
**Post date:** [November 7, 2006, 10:54am UTC](https://www.ruby-forum.com/t/a-column-named-type/74741/2 "2006-11-07T10:54:46Z")

</div>

Whoops…I see why. I had a blob type column in activities. When I  
specified, in the activity model,  
def self.scaffold\_fields  
[…whatever fields, just NOT the blob field]  
end

everything is happy. -Ralph
