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
精彩评论