firstdraft / appdev_template

A Rails template for generating homework projects
0 stars 1 forks source link

Override ActiveRecord Relation to_s #46

Closed jelaniwoods closed 5 years ago

jelaniwoods commented 5 years ago

Regards to this issue #104

Currently does this in the view templates

<p>
  Launch.where(id: 1)
<br/>
  <%= Launch.where(id: 1) %>
</p>
<p>
  Launch.all:
 <br/>
  <%= Launch.all %>
</p>

image

raghubetina commented 5 years ago

@jelaniwoods Have you tested this out with other ways of retrieving collections, e.g. from has_many or from scope?

jelaniwoods commented 5 years ago

@raghubetina it seems to work with has_many and scope

Screenshot (135) Screenshot (136)

The only reason I did Resource.last.context.resources is because the app I was testing this on apparently has a View Module called Context and that was taking precedence over the model.

raghubetina commented 5 years ago

@jelaniwoods Okie LGTM, I was thinking maybe we'd have to address ActiveRecord Collection Proxy, et al, also; but it looks like just Relation is enough. Nice!