Take a look (not my production code but reproduces the desired behavior):
``` ruby
class Post < ActiveRecord::Base
attr_accessible :published_at, :name
has_and_belongs_to_many :categories, :order => lambda {
[Category.arel_table[:published_at].desc, Category.arel_table[:name]] }
end
```
``` ruby
class Category < ActiveRecord::Base
attr_accessible :published_at, :name
has_and_belongs_to_many :posts, :order => lambda {
[Post.arel_table[:published_at].desc, Post.arel_table[:name]] }
end
```
``` ruby
Category.first.posts
# => TypeError: Cannot visit Proc
```
``` ruby
Post.first.categories
# => TypeError: Cannot visit Proc
```
The problem happens when we have a cross reference between two models and
need to use arel due to difference on quote of columns.
Sounds reasonable?
Reference: https://github.com/rails/rails/issues/6146
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Core" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-core/-/I5NDxR9PCvgJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en.