GithubHelp home page GithubHelp logo

acts-as-list's People

Contributors

ryanb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

acts-as-list's Issues

Missing license info

Hi,

what kind of license acts-as-list have? Can we include the license file and and update .gemspec?

Thank you.

bug in add_to_list_bottom

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

acts_as_list gem does not correctly assign position when model has a default_scope order(:position) in rails 3

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.