开发者

Sortable list. From PHP 5 to Rails 3

开发者 https://www.devze.com 2023-01-30 13:06 出处:网络
I am trying to develop a sortable list in Rails 3 using Jquery. I got it working a while back in PHP. How would the below code look in Rails 3?

I am trying to develop a sortable list in Rails 3 using Jquery. I got it working a while back in PHP. How would the below code look in Rails 3?

function reOrderSave()

{

    $page = $_P开发者_运维百科OST['page'];

    foreach ($page as $aco_order => $aco_id) {

        $data = array(
        'aco_order' => $aco_order

        );

        $this->db->where('aco_id', $aco_id);
        $this->db->update('fe_albums_content', $data);

    }

}

Thankful for all help!


Solved it!

This beautiful code is the Rails way, love it!

params[:page].each_with_index do |id, index|

    Element.update_all(['position=?', index+1], ['id=?', id])

end
0

精彩评论

暂无评论...
验证码 换一张
取 消