0

I just upgraded rails to 4.1 and am getting this error:

PG::SyntaxError: ERROR:  syntax error at or near "AS"
LINE 1: SELECT COUNT(count_column) FROM (SELECT  * AS count_column F...
                                               ^
: SELECT COUNT(count_column) FROM (SELECT  * AS count_column FROM (SELECT thread_id,     max(id) as id FROM "messages"  WHERE 1=0 AND (thread_id IS NOT NULL) GROUP BY thread_id) last JOIN messages ON messages.id = last.id LIMIT 5 OFFSET 0) subquery_for_count

Here is the method:

- as_myself do
    %li#messages-open.icon-btn.email
      - message_count = inbox_messages.count.is_a?(Hash) ? inbox_messages.count.values.first : inbox_messages.count
      - if(message_count.present? && message_count > 0)
        %span= message_count
1
  • SELECT * AS count_column is not a valid sql syntax. It should be something like SELECT <column_name> AS count_column Commented Sep 18, 2014 at 19:48

1 Answer 1

12

New syntax in rails 4.1 is count(:all) fixed my problem.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.