Using scope

I use the area to present some information to show completed domains and 24 hours a day.

scope :completed, joins(:user).where(:todos => { :complete => true })
scope :logged, completed.where("todos.updated_at <= ?", 1.day.ago)

Using regular todo partial

<%= render @user.todos.logged =>

However, I want to present these registered items in another partial _logged.html.erb. I just can’t understand how to correctly transfer the results of a region to concrete partial ones.

thank

+3
source share
2 answers

Well, if you want to partial for each element, yo can do:

<%=render :partial=> 'logged', :collection=>@user.todos.logged %>

Or, if you want to pass the entire array to one instance, you can do

<%=render :partial=> 'logged', :object=>@user.todos.logged %>

In both cases, I assume that your object will be called logged.

, <%= logged.title %>, , .

+7

-, , , . :

<%= render :partial => 'some_partial',
:locals => {:some_variable => "somevalue",
:some_other_variable => some_other_variable} %>
0

Source: https://habr.com/ru/post/1791881/


All Articles