0

I have a folder views/home that contains the initial screen for a Rails app.

For some users, the home.index.html.erb displays a partial containing a list of workorkorders.

In other words I'm fetching a list of workorder and a list of worequests from the home/index.html.erb - therefore, I've added code to read the @workorders and @worequests into the home controller.

This is the code that fetches the workorders:

<% @workorders.notcompl.each do |workorder| %>

The home controller contains this code to fetch the workorders:

def index
  @workorders = Workorder.all

I'd like to have _agentopenrequests.html.erb fetch all of the worequests. So, I added the following to fetch the wore quests:

def index2
  @worequests = Worequest.all

But, in the partial thats executed from home/index.html.erb file, how do get the following line to use index2 instead of index?

  <% @worequests.notcompl.each do |worequest| %>

Should I put both @worequests and @workorders into index?


UPDATE1

I tried changing the home controller to this:

 def index
   @workorders = Workorder.all

   respond_to do |format|
     format.html # index.html.erb
     format.json { render json: Workorders3Datatable.new(view_context) }
   end

   @worequests = Worequest.all

   respond_to do |format|
     format.html # index.html.erb
   end
 end

But, I get

DoubleRenderError - Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action.

UPDATE2

Would it make more sense to have the partial in the worequests folder instead of home - so, the worequests controller gets used?

4

1 回答 1

0

如果index2只是拉一组磨损任务,您可以将其复制/移动到index动作中。

于 2013-07-10T21:43:33.137 回答