ryanb / acts-as-list Goto Github PK
View Code? Open in Web Editor NEWNOT MAINTAINED. Gem version of acts_as_list Rails plugin.
NOT MAINTAINED. Gem version of acts_as_list Rails plugin.
Migration:
class CreateFoos < ActiveRecord::Migration
def self.up
create_table :foos do |t|
t.integer :position
t.timestamps
end
end
def self.down
drop_table :foos
end
end
Model:
class Foo < ActiveRecord::Base
acts_as_list
default_scope order(:position)
end
Tests:
require 'test_helper'
class FooTest < ActiveSupport::TestCase
# Replace this with your real tests.
test "it creates foos with the correct position without any scoping" do
Foo.destroy_all
Foo.send(:with_exclusive_scope) do
Foo.create!
Foo.create!
@three = Foo.create!
end
assert_equal 3, @three.position
end
test "it creates foos with the correct position with a default_scope order(:position)" do
Foo.destroy_all
Foo.create!
Foo.create!
three = Foo.create!
assert_equal 3, three.position
end
end
The first test passes, the second test fails. Methinks the likely suspect for this issue is line 196 within the bottom_item method:
# Returns the bottom item
def bottom_item(except = nil)
conditions = scope_condition
conditions = "#{conditions} AND #{self.class.primary_key} != #{except.id}" if except
acts_as_list_class.find(:first, :conditions => conditions, :order => "#{position_column} DESC")
end
Hi,
i have following problem on my app
@navigation.remove_from_list is working
@navigation.add_to_list_bottom is not working
if i remove @navigation.add_to_list_bottom from the transaction the rest of transaction works without problems
class Navigation < ActiveRecord::Base
acts_as_list :scope => 'section = '#{section}''
end
class Admin::NavigationsController < Admin::Namespace
def change_section
@navigation = Navigation.find(params[:navigation_id])
Navigation.transaction do
@navigation.remove_from_list
@navigation.section = params[:section]
@navigation.save
@navigation.add_to_list_bottom
end
flash[:notice] = 'navigation was successfully updated.'
render :update do |page|
page.reload
end
end
end
There are several issues with 0.1.2 of this lib that rails/acts_as_list has addressed. Can we update the rails gem to use that version instead?
Hi,
what kind of license acts-as-list have? Can we include the license file and and update .gemspec?
Thank you.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.