Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

Rails+ActiveAdmin - filtering with ransacker throws an error PG::SyntaxError: ERROR: syntax error at or near ","

So I found the solution:

First, I've changed my filter in admin/account.rb from

filter :by_active_projects_eq


filter :by_active_projects_in,
         :as => :string

This approach resulted in correct SQL generation,

"accounts"."id" IN

After that I also had to change my ransacker from

ransacker :by_active_projects,
formatter: proc{ |v|
    data =
    data ||= nil
  } do |parent|


ransacker :by_active_projects,
formatter: proc{ |v|
    data =
    data.present? ? data : nil
  } do |parent|

because the way it was implemented also caused incorrect query: for example there are no such accounts that have exactly 5 active projects. In that case

data =

returned "Empty Array", and dealing with this Array with data ||= nil never actually returned nil, and that resulted in SQL like this:

 1 AS count_column FROM "accounts"  WHERE
"accounts"."deleted_at" IS NULL AND
"accounts"."id" IN () LIMIT 30 OFFSET 0)

notice the "accounts"."id" IN () part, that was causing trouble.

After replacing data ||= nil with data.present? ? data : nil, if data was not present it was assigned a nil, and that part in SQL was generated corectly: "accounts"."id" IN (NULL)

Categories : Ruby

Related to : Rails+ActiveAdmin - filtering with ransacker throws an error PG::SyntaxError: ERROR: syntax error at or near ","
MySQL ALTER Stament for Exchange Partition throws syntax error
Here is an excerpt from the MySQL documentation In MySQL 5.6, it is possible to exchange a table partition or subpartition with a table using ALTER TABLE pt EXCHANGE PARTITION p WITH TABLE nt, You are getting error cause it's not supported in MySQL5.2 version. To check that, try changing the version 5.6 to 5.2 in the documentation URL[Magic Trick].

Categories : Mysql
PHPBB Parse error: syntax error, unexpected '}' overall_header.html.php
Actually this is very simple error you are talking about. This should be solved by yourself. Use PHP Syntax Checker or other tools for this.

Categories : PHP
Parsing error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';'
You started the echo string with double quotes and the src=".." and alt=".." have double quotes, so you will need to use single ' or escape it with "

Categories : PHP
Using a rails helper in haml, passing a hash causes syntax error
I think you just need to replace the curly brackets with the regular ones in your helper, try this: = nav_big( profile: @user, art: root_url, stories: root_url, universes: root_url, elements: root_url ) if you prefer the curly brackets then you should use this format = nav_big { :profile => @user, :art => root_url, :stories => root_url, :universes => root_url, :elements => root_url }

Categories : Ruby On Rails
PHP Dice IoC - Parse error: syntax error, unexpected '.'?
The vararg/splat operator (...) is a new feature introduced in PHP 5.6. Strange that a popular library relies on such obscure syntax but it seems you have to upgrade for your code to successfully run. PHP 5.6 New features PHP 5.6 and the Splat Operator

Categories : PHP
Recently Add
Parsing through nested hash using .present? - undefined method `[]' for nil:NilClass (NoMethodError)
"params" doesn't work in Ruby (Sinatra framework)
Specifying a Puppet + Ruby version matrix in CircleCI
How to upload a file using RestClient in Ruby?
Shibboleth authentication in Rails
Random, intermittent "argument out of range" error while parsing CSV and parsing time
Ruby: Wrong number of Arguments for a subclass changes number of arguments
amalgamate two ruby arrays
Geocoder request.location returns nil
Access most recent table row and its data
how to search multiple word in the same file using ruby and the get the output which contains those words
MongoDB search query for stats
rake command parsing options after --
Ruby: cannot load such file - LoadError
Understanding attributes in AWS DynamoDB with Ruby
Ruby: Get last character from user input
Undefined method 'delegate' for capybara::dsl::module
neo4j ruby wrapper create or update
'on raise' hook in ruby
Ruby OCI8 - bind optional parameters to Oracle Stored procedure
How to install the app only once for the suite
Different test unit output in Rubymine and console
Can Rake run each test in a separate Ruby instance?
Ruby strftime in UK format i.e. dd/mm/yy
Accessing hash in Ruby like objects in Coffeescript
How do I correct my script, that it doesn't matter what file name has the .xml that is uploaded?
Ruby: Tests not runing
Do I have to install Ruby on my Apache server to run scripts
Ruby: Does Test::Unit still exist?
How do I make a form that changes color with input text in Ruby?
© Copyright 2017 Publishing Limited. All rights reserved.