Update relation without id table

Why can’t I update this row?

cs = c.campaigns_segments.first
=> #<CampaignsSegments segment_id: 1, campaign_id: 1, sortable: nil>

cs.update_attribute(:sortable, 1)
NoMethodError: undefined method eq' for nil:NilClass from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.0/lib/active_support/whiny_nil.rb:48:inmethod_missing’
from
/Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/persistence.rb:256:in
update' from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/locking/optimistic.rb:77:inupdate’
from
/Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/attribute_methods/dirty.rb:68:in
update' from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/timestamp.rb:60:inupdate’
from
/Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/callbacks.rb:285:in
update' from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.0/lib/active_support/callbacks.rb:413:in_run_update_callbacks’
from
/Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/callbacks.rb:285:in
update' from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/persistence.rb:247:increate_or_update’
from
/Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/callbacks.rb:277:in
create_or_update' from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.0/lib/active_support/callbacks.rb:423:in_run_save_callbacks’
from
/Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/callbacks.rb:277:in
create_or_update' from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/persistence.rb:39:insave’
from
/Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/validations.rb:43:in
save' from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/attribute_methods/dirty.rb:21:insave’
from
/Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/transactions.rb:237:in
save' from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/transactions.rb:289:inwith_transaction_returning_status’
from
/Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:139:in
transaction' from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/transactions.rb:204:intransaction’
from
/Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/transactions.rb:287:in
with_transaction_returning_status' from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/transactions.rb:237:insave’
from
/Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/transactions.rb:248:in
rollback_active_record_state!' from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/transactions.rb:236:insave’
from
/Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/persistence.rb:117:in
`update_attribute’

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