开发者

Sortable list. From PHP 5 to 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜