Skip to main content

Questions tagged [acts-as-list]

ActsAsList is a Rails plugin that provides list abilities to an ActiveRecord model

acts-as-list
0 votes
2 answers
102 views

Is there a way to use acts_as_list with a single parent but many different children?

I've stumbled upon this Rails - acts_as_list with multiple Models. I'm having a hard time understanding how to fit the solution into my current use case. In my app, I have a section. The section can ...
Dennis Martinez's user avatar
1 vote
1 answer
174 views

Is there a way to scope acts_as_list based on column in another table?

TLDR: Is there a way to scope acts_as_list into another table as such class SprintTodo < ApplicationRecord belongs_to :sprint belongs_to :todo acts_as_list scope: [:sprint, :todo.status] end ...
Sawaid's user avatar
  • 77
0 votes
1 answer
580 views

Error with Rails Sortable - Cannot read properties of undefined (reading 'dataset')

I followed this tutorial to implement drag and drop. https://www.driftingruby.com/episodes/drag-and-drop-with-hotwire I am getting an error on drop that says Uncaught (in promise) TypeError: Cannot ...
spacerobot's user avatar
0 votes
1 answer
511 views

Uncaught TypeError: $(...).sortable is not a function in Rails 6

Strugle alot but couldn't solve this problem. It been nightmare for me. I am using rails 6. and jquery ui "jquery-ui": "^1.13.0". I have added gem gem 'acts_as_list' and added ...
Sanju Basnet's user avatar
1 vote
2 answers
406 views

How to add position column to acts_as_list on existing database records in Rails migration?

I have seen How to change a nullable column to not nullable in a Rails migration? for the problem of adding a non-nullable column to an existing database table with existing records. As such, I am ...
Alien's user avatar
  • 1,112
1 vote
1 answer
194 views

Having trouble extending ActiveStorage::Attachment with acts_as_list

Can someone offer best practices for adding acts_as_list to active storage attachments? The gem requires "acts_as_list" added to the model in question. I am hesitant to edit the ...
Scott Tallarida's user avatar
1 vote
1 answer
246 views

Ruby on Rails - Does ActsAsList have known problem when working with nested_attributes?

I am having a problem when updating acts_as_list positions with nested_attributes, I have worked my way down and noticed the issue is still happening on the model level (as shown below). The problem ...
k.jobbins's user avatar
  • 113
0 votes
2 answers
1k views

How to get the right position with Sortable.js, acts_as_list and Stimulus for nested_attributes

I'm trying to implement the "Drag and Drop Sortable Lists" (https://gorails.com/episodes/rails-drag-and-drop-sortable) with nested_attributes. Unfortunately, I'm getting the wrong :position. ...
Mirha Masala's user avatar
0 votes
1 answer
86 views

Rails Access Geocoder::Calculations

Hi All I have a little app that takes an address on the stop model and geo codes it via geocoder gem class Stop < ApplicationRecord belongs_to :trip acts_as_list scope: :trip after_validation ...
Jeremy Bray's user avatar
0 votes
2 answers
1k views

How to handle drag and drop between multiple lists using SortablejS and acts_as_list gem?

I've been searching for a day and a half for a solution. I've got several tables (Categories) that allow the user to drag and drop each row (Item) to reorder the position of each item on that table (...
J. Jackson's user avatar
  • 3,766
1 vote
1 answer
336 views

acts_as_list on has_many :through and sortablejs

I have a fairly large question that I've been unable to resolve after a full day of reading articles, documentation and other Stack questions. At this point it's just messing with my mind! I have an ...
J. Jackson's user avatar
  • 3,766
0 votes
1 answer
827 views

acts_as_list puts record at wrong position with array scope

I have a model with following setup for acts_as_list gem: acts_as_list scope: [parent_id: nil], add_new_at: :top, top_of_list: 0 I expect having next array of records: [Record id: 1, parent_id: nil, ...
mitsuka s's user avatar
2 votes
1 answer
4k views

Rails gem acts_as_list: How to handle reordering of list items when a list item is destroyed?

I'm using acts_as_list v0.9.17 this way: class ListItem < ActiveRecord::Base acts_as_list scope: [:column1_id, :column2_id], :add_new_at => :bottom end When a new (scoped) @list_item is ...
Backo's user avatar
  • 18.7k
0 votes
1 answer
693 views

Rails gem acts_as_list, scoping the position to the user

I am using Rails 4 and the ActsAsList gem to give our Project model a position. Projects can be owned my one user, and collaborated on with many users. When a user re-orders their projects, it affects ...
Emily Kingan's user avatar
0 votes
1 answer
238 views

ordering a many_to_many relationship in rails

I would like to implement a drag and drop of a list of items in a playlist. Playlist contents are of different activerecord types. I need to store the position and persist it in the database and ...
Ayrad's user avatar
  • 4,006
1 vote
1 answer
77 views

Stack level too deep when calling remove_from_list from acts_as_list gem

I'm running a test that did not fail before upgrading to rails 5.0, but now I am getting stack level too deep, the test is as follows: describe "item hierarchy" do before(:each) do @...
marimaf's user avatar
  • 5,410
0 votes
1 answer
453 views

Acts as paranoid gem interferes with acts as list

I use both acts_as_paranoid and acts_as_list for the same model, CheckIn. I have the gem setup as follows: class CheckIn < ActiveRecord::Base acts_as_paranoid belongs_to :client ...
Jeremy Thomas's user avatar
0 votes
1 answer
245 views

How to use remove_from_list method of ActiveRecord with scope as public in the model?

Lets say my model is C . Obj - @c C has acts_as_list gem defined as acts_as_list scope: '...' and scope as : scope :public -> {where (some_condition)} When writing rspec for @c.remove_from_list , ...
Afan's user avatar
  • 69
0 votes
1 answer
135 views

Acts as list with a subgroup

I'm using the popular gem, acts_as_list and I am having issue with getting the scope to work. Basically there're three models, a group, a subgroup, and a thing. A group has many subgroups and a ...
Charlie Massry's user avatar
1 vote
2 answers
265 views

acts_as_list upper_limit on position

I am using acts_as_list on my model.I have a position column on that model for which I don't wan't the model object to be saved to the database if the position is more than my upper-limit.(I tried ...
Adil Hussain's user avatar
1 vote
1 answer
205 views

added `acts_as_list` to gemfile, rails gives error :`bundler: failed to load command: rails` when running rails s

I added the gem acts_as_listto my gemfile. Now when I run bundle exec rails s the server crashes and gives the error : bundler: failed to load command: rails (/Users/dadi/.rbenv/versions/2.3.1/bin/...
Slowboy's user avatar
  • 591
0 votes
1 answer
463 views

acts_as_list with paranoia gem

I have two models. The first ModelA is the parent of ModelB. ie ModelA has_many ModelB. [When modelA is destroyed, all its dependent ModelB's also gets destroyed due to dependent destroy Now I have ...
Adil Hussain's user avatar
0 votes
1 answer
881 views

Using acts_as_list, set scope to string column

Using acts_as_list, I'm trying to set the scope to the where column. acts_as_list scope: :where where is the name of a string column in the model. But when I'm getting this error: undefined ...
mahmoodi's user avatar
0 votes
1 answer
578 views

multi position column with acts_as_list

How to use multi position columns with acts_as_list gem ? for sample : rails g migration AddPositionToTodoList position:integer position2:integer position3:integer controller: todo_list = TodoList....
mamali's user avatar
  • 1
2 votes
0 answers
199 views

'last' method not returning last item in array in RSpec test - Rails4 Ruby 2.1.2

Was working on an RSpec test that copies @protocol to @dest and saw this: [26] pry(#<RSpec::ExampleGroups::ProtocolsController::ProtocolCopy>)> @protocol.step_items.count => 3 [27] pry(#&...
Perry Horwich's user avatar
1 vote
0 answers
153 views

Sort collection after associated resource's acts_as_tree/acts_as_list order

I have a SuccessCriterion model that implements both acts_as_tree and acts_as_list so it can be arranged as sorted tree hierarchy. Every success criterion can has many Boilerplate objects. class ...
Joshua Muheim's user avatar
0 votes
1 answer
276 views

Ruby gem dependency loading

I'm putting some shared models for a rails app inside it's own gem. It's just models, so I'm not using an engine. Getting it set up seemed to work fine until I added the "acts_as_list" gem. # gem - ...
Shaun's user avatar
  • 2,032
0 votes
1 answer
61 views

Maintain order of saved attributes list for model

I have two models with a has_many to has_many relationship through a join table. class Article < ActiveRecord::Base has_many :authorings, -> { order(:position) }, :dependent => :destroy ...
npresco's user avatar
  • 183
2 votes
1 answer
890 views

Rails: How can I incrementally add items to a sorted list in one view

I am trying to create a set list app for musicians. Users can upload their repertoire of songs & pick songs from a list of those songs to populate a set list for a specific performance. See ...
Brian K's user avatar
  • 75
0 votes
1 answer
754 views

Rails: Ancestry + Acts_as_List Gems Not Working as Expected When Changing Parent Object

I have a Ruby on Rails 3 app which uses the ancestry gem to provide a hierarchical tree structure for a model in combination with the acts_as_list gem to provide explicit positioning within each level ...
dSquared's user avatar
  • 9,795
1 vote
1 answer
1k views

How to make acts_as_list make the added item have the top position?

I have a group of items which uses the acts_as_list gem. As of now, when a new item is added, acts_as_list will give the item the lowest position, making it show up as the last item on the list. Is ...
Jill's user avatar
  • 533
1 vote
4 answers
1k views

Set Position Value from Index for nested model attributes

How can I set a position field in the attributes for a nested model so that my has_many relationship remembers it's sort order? I want to set the position from the index so that it reflects the order ...
Will's user avatar
  • 4,651
0 votes
1 answer
1k views

Can I use Single Table Inheritance with has_many to get a collection of multiple types

I have a Citation class and I want each Citation to have many Resources. A resource can be a LocalFile, Link (and maybe something like a dropbox file). Resources will share most functionality and ...
Peter Gerdes's user avatar
  • 2,806
1 vote
0 answers
104 views

rails acts_as_list specific to user and date

I'd like to use acts_as_list in my stock market application but the ordering position should be specific to the user, the ticker and date. acts_as_list scope: [:user_id, :ticker, :market_date] So, ...
JP.'s user avatar
  • 5,586
2 votes
0 answers
257 views

How to update acts_as_list using multiple columns

I have a Rails 3.2 app that uses acts_as_list on two columns in the same model: This is in the costproject model: acts_as_list :column => :division_priority, :scope => :client acts_as_list :...
Reddirt's user avatar
  • 5,943
1 vote
0 answers
55 views

acts_as_list how to add a second list based on related table column

In a Rails 3.2 app I'm trying to add an acts_as_list to the model costproject. Client model: belongs_to :department Costproject model: belongs_to :client Both department_priority is in ...
Reddirt's user avatar
  • 5,943
1 vote
0 answers
73 views

acts_as_list wipes out parent model's virtual attribute when calling destroy on child model

I have a Parent model which has_many children and also a virtual attribute: attr_accessor :new_assocation_model has_many :children, -> { order("position ASC") }, autosave: true, inverse_of: :...
hoanewton's user avatar
0 votes
1 answer
429 views

Can I use as act-as-list with a polymorphic association?

I am working on a liquid democracy app. My data model is: Both Users and Organizations are Voters. A Voter has an ordered list of Delegations. A Delegation consists of a set of Tags and an ordered ...
dysbulic's user avatar
  • 3,055
0 votes
1 answer
145 views

Rails jQuery sortable unable to save

I'm trying to make my table sortable (drag and drop) using jQuery, the problem I'm having is saving the new sorted table and then publishing it to other users or when the browser is refreshed. I'm ...
neo's user avatar
  • 4,118
0 votes
1 answer
45 views

AR equivalent to these SQL statements or how otherwise to use them in Rails?

I wanted to use the gem acts_as_list to reorder lists. But it doesn't seem to handle more restricted queries than association-based (I want to order lists based both on an association AND objects ...
Fellow Stranger's user avatar
1 vote
0 answers
188 views

Restrict scope in acts_as_list

class TodoList < ActiveRecord::Base has_many :todo_items, -> { order("position ASC") } end class TodoItem < ActiveRecord::Base belongs_to :todo_list acts_as_list scope: :todo_list end ...
Fellow Stranger's user avatar
0 votes
1 answer
234 views

Conditionally activate "acts_on_list" when field is defined

I have a model "entry" and I need it to act like a list when a playlist_id is specified, but if it's not, I need it to not act like a list. (acts_as_list is a gem I'm using) In my model code I have: ...
RandallB's user avatar
  • 5,515
0 votes
1 answer
2k views

Rails 4: acts_as_list with complex scope

My model has a string field, bar, that is either a, b, or c. It uses has_ancestry and acts_as_list. I want the list to be scoped on (1) the ancestry, and (2) bar, but I want a and b to be in the same ...
Peter's user avatar
  • 395
0 votes
1 answer
2k views

acts_as_list "NoMethodError (undefined method `position_was' for xxx)"

I'm trying to update the theme_name using Best In Place. At the moment however, it throws an error: NoMethodError (undefined method `position_was' for #<Fruit:0x000000037e80a8>): app/...
Jragon's user avatar
  • 45
0 votes
1 answer
512 views

acts_as_list in multi-tenant application - how do I set the scope?

Question I'm using acts_as_list in a multi-tenant app. I modeled the multi-tenancy using this Railscast: #388 Multitenancy with Scopes (subscription required). I need to ensure my around_filter ...
JoshDoody's user avatar
  • 427
0 votes
1 answer
766 views

dependent destroy with acts_as_tree and acts_as_list

Currently I upgrade rails 2 application to rails 3.2.13 wich use acts_as_tree and acts_as_list. Before, the upgrade it works well. Since, I have a problem with acts_as_tree and acts_as_list with ...
CupraR_On_Rails's user avatar
0 votes
1 answer
221 views

Trouble update has_many :through record

I am having an issue updating a has_many through record. Here is my setup: class TastingGroup < ActiveRecord::Base has_many :group_wine has_many :wines, through: :group_wine end class ...
Paul's user avatar
  • 401
0 votes
1 answer
511 views

Ordering a has_many list in view

I have a model called Person that the user selects five personality Traits for. However, the order they pick them for matters (they are choosing most descriptive to least descriptive). I know how to ...
Kansha's user avatar
  • 570
4 votes
1 answer
2k views

rails: sort a has_many using :order is not working due to order by timestamp

I have a rails model let say User with a has many relationship with Post. Post contains an attribute named position that stores the position (acts_as_list gem). The position stores the position on the ...
Mateu's user avatar
  • 2,678
1 vote
2 answers
1k views

prevent default scope from being applied to acts_as_list

I use acts_as_list to generate slot numbers of books: acts_as_list :scope => :book_id, :column => :slot and have a default scope that prevents deleted (soft delete) books from getting in to ...
amit_saxena's user avatar
  • 7,588

15 30 50 per page