Odd behavior on update

If I have the following two legacy data tables:

CREATE TABLE statusactivities (
id int(11) NOT NULL auto_increment,
activity int(11) NOT NULL default ‘0’
)

CREATE TABLE activities (
id int(11) NOT NULL auto_increment,
activity varchar(60) NOT NULL default ‘’
)

And thus, the two models:

class Statusactivity < ActiveRecord::Base
set_table_name ‘statusactivities’
belongs_to :activity, :foreign_key => ‘activity’
end

class Activity < ActiveRecord::Base
set_table_name ‘activities’
has_many :statusactivities, :foreign_key => ‘activity’
end

and I go to update a Statusactivity, I get the following exception.
Please note at the bottom, the parameters – it doesn;t appear to
be anything wrong here to me. Can someone please enlighten me as
to what I may have specified wrong here that I am unable to update
a record here? (I am using scaffolding_extensions btw) - Ralph V.

ActiveRecord::AssociationTypeMismatch in
CrudController#update_statusactivity

Activity expected, got String

C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/associations/association_proxy.rb:134:in
raise_on_type_mismatch' C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/associations/belongs_to_association.rb:22:inreplace’
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/associations.rb:850:in
activity=' #{RAILS_ROOT}/vendor/plugins/scaffolding_extensions/lib/scaffolding_extensions.rb:344:insend’
#{RAILS_ROOT}/vendor/plugins/scaffolding_extensions/lib/scaffolding_extensions.rb:344:in
update_scaffold_attributes' #{RAILS_ROOT}/vendor/plugins/scaffolding_extensions/lib/scaffolding_extensions.rb:343:ineach’
#{RAILS_ROOT}/vendor/plugins/scaffolding_extensions/lib/scaffolding_extensions.rb:343:in
update_scaffold_attributes' #{RAILS_ROOT}/vendor/plugins/scaffolding_extensions/lib/scaffolding_extensions.rb:985:inupdate_statusactivity’
C:/INSTAN~2/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:941:in
`send’

Request

Parameters: {“commit”=>“Update statusactivity”, “id”=>“1”,
“statusactivity”=>{“activity”=>“1”}}

and I go to update a Statusactivity, I get the following exception.

The problem is when you are doing the above activity, can you post the
code?

thanks,
andy


Andrew S.

There isn;t any other than the model descriptions above – the rest is
handled by scaffolding_extensions plugin. -Ralph

On 11/3/06, Ike [email protected] wrote:

There isn;t any other than the model descriptions above – the rest is
handled by scaffolding_extensions plugin. -Ralph

You can’t have your belongs_to association have the same name as your
foreign key. Change the foreign key to activity_id or rename the
belongs_to association.

Jeremy

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs