Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rails polymorphic query

Why is it that

@discussions = Discussion.where(:discussable => @discussable) 

doesn't work. yet this work:

@discussions = Discussion.where(:discussable_id => @discussable.id, :discussable_type => @discussable.class.to_s)

Thanks.

like image 876
randomor Avatar asked Aug 12 '26 09:08

randomor


1 Answers

Looks like pull request which fixes this issue was merged into master 1 month ago:

https://github.com/rails/rails/pull/7273

Unfortunately, it will be only released in Rails 4 :(

like image 127
Andrey Chernih Avatar answered Aug 15 '26 06:08

Andrey Chernih



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!