我想问一下我是否可以在一个页面上使用will_paginate插件两次?例如,我有一个男性用户的表和一个页面或一个视图中的女性用户的表,我需要分页两个表.我的问题是这个问题的解决方案是什么?
所以我在我的通讯发布申请中有这个大方法.方法是更新人造丝,我需要将用户分配给人造丝.我有关系n:n通过表colporteur_in_rayons有属性since_date和until_date.
我是一名初级程序员,我知道这段代码非常虚拟:)我很欣赏每一个建议.
def update
rayon = Rayon.find(params[:id])
if rayon.update_attributes(params[:rayon])
if params[:user_id] != ""
unless rayon.users.empty?
unless rayon.users.last.id.eql?(params[:user_id])
rayon.colporteur_in_rayons.last.update_attributes(:until_date => Time.now)
Rayon.assign_user(rayon.id,params[:user_id])
flash[:success] = "Rayon #{rayon.name} has been succesuly assigned to #{rayon.actual_user.name}."
return redirect_to rayons_path
end
else
Rayon.assign_user(rayon.id,params[:user_id])
flash[:success] = "Rayon #{rayon.name} has been successfully assigned to #{rayon.actual_user.name}."
return redirect_to rayons_path
end
end
flash[:success] = "Rayon has been successfully updated."
return redirect_to rayons_path
else
flash[:error] = "Rayon has not been updated."
return redirect_to :back
end …Run Code Online (Sandbox Code Playgroud)