Skip to content

bug in add_to_list_bottom #1

Open
PsychoPhobic opened this Issue Mar 28, 2010 · 2 comments

2 participants

@PsychoPhobic

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

@nono
nono commented Mar 28, 2010

Hi,

can you explain what is not working? It throws an exception? The position is not set?

@PsychoPhobic

i did't see the error before because its at ajax request
but now i edited the controler and see the reason is add_to_list_bottom is private (i didn't see that before)

but i didn't see any other public function is give this funktionality

posibility 1

maybe you can edit add_to_list_top and add_to_list_bottom for public use
and raise an error if object is already in list OR refer to functions move_to_top and move_to_bottom in this case

posibility2
dont edit add_to_list_top and add_to_list_bottom
and add to insert_at(position = 1) :top and :bottom as posible parameters (or maybe -1 for last like in Array)

posibility3
i don't know if its possible but maybe you can also add a function which can include all the 4 functions in my transaction by set a new parameter for :scope
if its defined like acts_as_list :scope => 'section = '#{section}''

regards

Stefan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.