ruby on rails - is there anyway to combine these into one ActiveRecord query? -


I am thinking that both of these questions are there to connect together where without By using the string (... notifiable_type = & gt; "post" ,: notifiable_id => post.id) notification. Where (: notifiable_type = & gt; "comment",: Notifiable_id => post.comments.map (& amp; id))

In other words, I have to do without Looking for a method:

  notification. ("(Notifiable_type = 'post' and notifiable_id =?) Or (notifiable_type = 'comment' and (?)) Notifiable_ id", [post] .id, post.comments.map (& amp; id)])   

Is this possible?

You can use to get it in a clean and readable way:

  notification. Where ((:: notifiable_type = & gt; "post" & amp;; notifiable_id = & gt; post.id) | (: Notifiable_type = & gt; "Comment" & amp ;: notifiable_id = & gt; [post.comments .map (& amp; amp;; id)))    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

memcached - Django cache performance -