ruby on rails - Filter the loaded data using ROR -


i first preload activerecord one-to-many active records. possible filter out data followings without querying database again?

animal = @animals.all.includes({:cats}) animal.where([:cat_category=>"home_cat"]) ### 1 

if located inside method, example

def load_something   animal = @animals.all.load([:cats])   animal.where([:cat_category=>"home_cat"]) ### 1 end 

rails smart enough make 1 request db. if check in rails console, 1 line, type other, make 2 requests, in app, rails amke 1 db request


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -