SimpleRecord & collections of partials

7 views
Skip to first unread message

Pawel Szymczykowski

unread,
Feb 1, 2011, 5:45:56 PM2/1/11
to SimpleRecord
Hi all,

SimpleRecord on rails is working great for me so far, but I ran into a
problem using it with partials. I'm not sure if I'm missing something
obvious.. I'll probably look into the rails sources later on to see
what exactly is happening, but so far I know that this works:

<% @images.each do |image| %>
<%= render :partial => 'image', :object => image %>
<% end %>

..but this does not:

<%= render :partial => 'image', :collection => @images %>

I noted that @images turns out to be an instance of
SimpleRecord::ResultsArray - maybe it doesn't implement something the
render collection code is looking for? Has anyone looked into this /
worked around it before?

Thanks!

Travis Reeder

unread,
Feb 1, 2011, 9:22:15 PM2/1/11
to simple...@googlegroups.com
Sounds like you're probably correct. Can you post the error message and backtrace?


--
You received this message because you are subscribed to the Google Groups "SimpleRecord" group.
To post to this group, send email to simple...@googlegroups.com.
To unsubscribe from this group, send email to simple-recor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/simple-record?hl=en.


Pawel Szymczykowski

unread,
Feb 1, 2011, 11:24:30 PM2/1/11
to SimpleRecord
That's the funny part - no errors whatsoever - just no result.

I think I've found it though.. check out this line from actionview:

https://github.com/rails/rails/blob/master/actionpack/lib/action_view/renderer/partial_renderer.rb#L94

I'm now able to get results by adding this:

class SimpleRecord::ResultsArray
def to_ary
self
end
end

Is it possible to get a patch in for that?

On Feb 1, 6:22 pm, Travis Reeder <tree...@gmail.com> wrote:
> Sounds like you're probably correct. Can you post the error message and
> backtrace?
>
> On Tue, Feb 1, 2011 at 2:45 PM, Pawel Szymczykowski <make...@gmail.com>wrote:
>
>
>
>
>
>
>
> > Hi all,
>
> > SimpleRecord on rails is working great for me so far, but I ran into a
> > problem using it with partials. I'm not sure if I'm missing something
> > obvious.. I'll probably look into the rails sources later on to see
> > what exactly is happening, but so far I know that this works:
>
> > <% @images.each do |image| %>
> > <%= render :partial => 'image', :object => image %>
> > <% end %>
>
> > ..but this does not:
>
> > <%= render :partial => 'image', :collection => @images %>
>
> > I noted that @images turns out to be an instance of
> > SimpleRecord::ResultsArray - maybe it doesn't implement something the
> > render collection code is looking for? Has anyone looked into this /
> > worked around it before?
>
> > Thanks!
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "SimpleRecord" group.
> > To post to this group, send email to simple...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > simple-recor...@googlegroups.com<simple-record%2Bunsubscribe@goog legroups.com>
> > .
Reply all
Reply to author
Forward
0 new messages