ruby - Hide record in Rails model if nested_attributes are empty -
I have two models in the Railway app: What should I add to my You can add static method to the listing model: and then simply call easily : listing and
ListingPhoto . I want to create some kind of scope for my model which removes
listing s which is not nested
ListingPhoto s is being pulled from the external API, so my There is no easy way to control these savings.
Listing looks like this:
entering the class & lt; looks like this:
code> class listing photo & lt; ActiveRecord :: Base is_to: Listing Valid: Listing, Attendance: Right Mount_uploader: Photo, Photo Uploader and
listing model to stop Show listing with empty picture set?
def Self.with_photos includes (: listing_photos) .where.not (: listing_photos = & gt; {: listing_id = & gt; blue}} end
listing. With_photos
Comments
Post a Comment