Using acts_as_list storing the information in a session

Hi,

I have an order model that i am storing in a session, that is not
currently in the database. I am updating the page using ajax, and I do
not want to store the order in the database untill it is completely
filled out.

I have order_items that I am adding to the order, and I have used the
acts_as_list within the order_item model.

My problem comes when i try and rearrange the order_items using the
following code:

def move_item_up
@order = find_order
@order.order_items[params[:id].to_i].move_higher
@order.reload
session[:order] = @order
render:partial => ‘order_contents’
end

It gives me the following error:

ActiveRecord::RecordNotFound (Couldn’t find Order without an ID):
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:939:in
find_from_ids' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:382:infind’

This is happening with the reload function, which i am assuming tries to
refresh the order_items in the order, by gathering them from the
database.

Is there another way to do this, where I can still hold these within the
session, without having to store them in the database?

Thanks,
Ryan

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs