Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

When updating the "scope" attribute, the element is not "added" to the current list #8

Open
RiceT-zz opened this issue Sep 29, 2010 · 0 comments

Comments

@RiceT-zz
Copy link

Hi all
Models (Rails 3 application):
class NetworkService < ActiveRecord::Base
has_many :network_classes, :foreign_key => "network_id", :order => :position
end
class NetworkClass < ActiveRecord::Base
belongs_to :class_definition, :foreign_key => "class_id"
belongs_to :network_service, :foreign_key => "network_id"
acts_as_list :scope => :network_id
validates_presence_of :class_id, :network_id
attr_accessible :class_id, :network_id
end

Case:

  • when I create an element in NetworkClass, no problem it goes straight at the end of the current list.
  • when I update the "network_id" attribute which holds the "scope", the record is saved with a "position" set to 1, no matter if there are already records with the same "network_id". I would expect that the "position" of the updated record is set to the (last position + 1) of the list corresponding to the new "network_id" value. You then end up with multiple records with the same position in the list.
  • note: the NetworkClass "belongs to" another "class_definition" table, but not concerned with the list (I guess)

Many thanks for the gem anyway

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant