Reputation: 409
def index
@posts = Post.published
respond_to do |format|
format.html # index.html.erb
format.json { render json: @posts }
format.atom
end
end
I am taking this error.And I am new on RoR Can anybody help me.What can I do now ?
Upvotes: 1
Views: 2230
Reputation: 23939
You have defined a scope but gave it a relation instead of a proc. You probably have something like this:
class Post < ActiveRecord::Base
scope :published, where(published: true)
end
Change it to this:
class Post < ActiveRecord::Base
scope :published, -> { where(published: true) }
end
In the future, always post the entire stack trace, and the methods involved. It's not always this easy to guess what's going on.
Upvotes: 8