I want to return an int from a find_by_sql call. But when I use that
result to compare to another count the error tells me I have an array.
MODEL:
# Returns the number of comments in a specified post
def self.find_count(post_id)
find_by_sql(["SELECT COUNT(*) FROM commments WHERE post_id = ?",
post_id])
end
CONTROLLER:
def test
@post = Post.find(@params[“post_id”])
@comment =
Comment.find_next(@params[“post_id”], @params[“position”])
@count = Comment.find_count(@params[“post_id”])
end
VIEW:
line 1: <% if @comment.position < @count -%>
…
ERROR:
ActionView::TemplateError (comparison of Fixnum with Array failed) on
line #1 of app/views/main/_test.rhtml:
Do I have a syntax error?