# Trouble with Acts\_as\_list::move\_higher/lower

**URL:** <https://www.ruby-forum.com/t/trouble-with-acts-as-list-move-higher-lower/125476>\
**Category:** Rails\
**Created:** [January 9, 2008, 2:27pm UTC](https://www.ruby-forum.com/t/trouble-with-acts-as-list-move-higher-lower/125476 "2008-01-09T14:27:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![taro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/df705f/32.png) [@taro](https://www.ruby-forum.com/u/taro)\
**Post date:** [January 9, 2008, 2:27pm UTC](https://www.ruby-forum.com/t/trouble-with-acts-as-list-move-higher-lower/125476/1 "2008-01-09T14:27:13Z")

</div>

## I have the model MessageBoard acts\_as\_list for Forum, but for some reason, the function move\_higher/lower doesn’t seem to do its job in the test file I wrote for forum\_test.rb:

def test\_board\_up  
forum = Forum.new(:title =\> ‘basic’)  
assert forum.valid?, “forum is invalid, expect more failures”  
assert\_equal forum.title, ‘basic’  
board = []  
#initialize three boards in this order: #1, #3, #2  
#board array holds = [#1, #2, #3]  
board[0] = forum.message\_boards.build(:title =\> ‘#1’,  
:description =\> ‘one’)  
board[2] = forum.message\_boards.build(:title =\> ‘#3’,  
:description =\> ‘three’)  
board[1] = forum.message\_boards.build(:title =\> ‘#2’,  
:description =\> ‘two’)  
#save, just in case  
forum.save

# move the index #2 lower (so that it’s less than #3)

```
forum.message_boards[2].move_lower

```

# and save.

```
forum.save
board_temp = forum.message_boards
board_temp.each{|b| puts "\ntest_board_up order #{b.title}"}
for num in 0..2
  assert_equal board_temp[num].title, board[num].title
  assert_equal board_temp[num].description, board[num].description
end
forum.destroy

```

end

def test\_board\_down  
forum = Forum.new(:title =\> ‘basic’)  
assert forum.valid?, “forum is invalid, expect more failures”  
assert\_equal forum.title, ‘basic’  
board = []  
#initialize three boards in this order: #1, #3, #2  
#board array holds = [#1, #2, #3]  
board[0] = forum.message\_boards.build(:title =\> ‘#1’,  
:description =\> ‘one’)  
board[2] = forum.message\_boards.build(:title =\> ‘#3’,  
:description =\> ‘three’)  
board[1] = forum.message\_boards.build(:title =\> ‘#2’,  
:description =\> ‘two’)  
#save, just in case  
forum.save

# move the index #3 higher (so that it’s greater than #2)

```
forum.message_boards[1].move_higher

```

# and save.

```
forum.save
board_temp = forum.message_boards
board_temp.each{|b| puts "\ntest_board_down order #{b.title}"}
for num in 0..2
  assert_equal board_temp[num].title, board[num].title
  assert_equal board_temp[num].description, board[num].description
end
forum.destroy

```

## end

Loaded suite forum\_test  
Started  
.  
test\_board\_down order #1

test\_board\_down order #3

test\_board\_down order #2  
F.  
test\_board\_up order #1

test\_board\_up order #3

test\_board\_up order #2  
F…  
Finished in 0.615307 seconds.

1. Failure:  
test\_board\_down(ForumTest)  
[forum\_test.rb:152:in `test_board_down' forum_test.rb:151:in`each’  
forum\_test.rb:151:in `test\_board\_down’]:  
\<"#3"\> expected but was  
\<"#2"\>.

2. Failure:  
test\_board\_up(ForumTest)  
[forum\_test.rb:125:in `test_board_up' forum_test.rb:124:in`each’  
forum\_test.rb:124:in `test\_board\_up’]:  
\<"#3"\> expected but was  
\<"#2"\>.

## 10 tests, 43 assertions, 2 failures, 0 errors

While it may be possible I confused myself with the first test, and  
thus, see no activity there, the second test SHOULD result in some  
change. I saved object forum before calling move\_higher in the middle  
index, then saved again. However, according to my puts statement,  
nothing seemed to have happened at all in the middle index! Why is  
that?

---

<div class="post-metadata">

**Author:** ![taro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/df705f/32.png) [@taro](https://www.ruby-forum.com/u/taro)\
**Post date:** [January 9, 2008, 2:36pm UTC](https://www.ruby-forum.com/t/trouble-with-acts-as-list-move-higher-lower/125476/2 "2008-01-09T14:36:01Z")

</div>

On 9 Jan 2008, at 13:26, Taro wrote:

> I have the model MessageBoard acts\_as\_list for Forum, but for some  
> reason, the function move\_higher/lower doesn’t seem to do its job in  
> the test file I wrote for forum\_test.rb:

move\_higher/lower are calling update\_all : you’ll need to reload  
forum.message\_boards to see any change.

Fred

---

<div class="post-metadata">

**Author:** ![taro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/df705f/32.png) [@taro](https://www.ruby-forum.com/u/taro)\
**Post date:** [January 9, 2008, 3:06pm UTC](https://www.ruby-forum.com/t/trouble-with-acts-as-list-move-higher-lower/125476/3 "2008-01-09T15:06:32Z")

</div>

Ahhh…I see. Yes it works, thank you!

---

<div class="post-metadata">

**Author:** ![taro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/df705f/32.png) [@taro](https://www.ruby-forum.com/u/taro)\
**Post date:** [January 9, 2008, 3:14pm UTC](https://www.ruby-forum.com/t/trouble-with-acts-as-list-move-higher-lower/125476/4 "2008-01-09T15:14:10Z")

</div>

Out of curiosity, where can I find that method in the rails framework  
documentation? Being able to see the source would really help!

On Jan 9, 8:35 am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
