我一直在尝试安装和使用新的sync realtime partials gem,但是当我将代码放入我的视图时,一切都会出错。
这是我现有的代码,预先同步。
<%= render :partial => "tasks/table", :locals => { :assigned_to => true, :user_dashboard => false } %>
现在写着:
<%= sync partial: 'task_table', resource: @tasks %>
我在我的视图和任务文件夹中创建了一个同步文件夹,并添加到_task_table.html.erb中。
任务#index
中的NoMethodError显示/Users/callum/rails_projects/arc_app/app/views/tasks/index.html.erb第17行&gt;提出:
WillPagin :: Collection的未定义方法model_name:Class
在我的tasks_controller.rb中,我有
def index
@tasks = Task.search(params [:search])。order(sort_column +“”+ sort_direction).paginate(:per_page =&gt; 15,:page =&gt;&gt; params [:page])。 find_by_status(PARAMS [:状态])
端
我对rails非常陌生,但是,我猜测它与我的控制器中的@tasks有关,我也会从具有相同/类似错误的不同控制器处理该表。
答案 0 :(得分:0)
使用以下方式,不要混淆:
def index
user_task = case params[:status].present?
when true then Task.where(:status => params[:status]).all
else Task
end
@tasks = user_task.paginate(:per_page => 15, :page => params[:page]).search(params[:search])
end