Hi all;
Bit of an urgent plea here to help me understand how to adapt search
parameters in a Hobo Index function to satisfy PostgreSQL's strong typing.
I have a Plan class:
plan_no :decimal, :default => 0, :precision => 12, :scale => 3 #
to accommodate 123456789.999
clsr :integer
In my *index* method, I include these in search scopes:
scopes = {
:search => [ params[:search], :plan_no, :clsr ]
}
Then, I search:
@plans = Plan.regional(session[:region_id].to_i).apply_scopes(scopes)
But, Postgres is very unhappy about comparing the text I type in the Search
box with the decimal and integer fields *plan_no* and *clsr:*
HINT: No operator matches the given name and argument type(s). You might
need to add explicit type casts.
: SELECT "plans".* FROM "plans" WHERE (plans.region_id = 1) AND
(((plans.plan_no ILIKE '%4430%') OR (plans.clsr ILIKE '%4430%'))) DESC
LIMIT 40 OFFSET 0
*PG::UndefinedFunction: ERROR: operator does not exist: numeric ~~*
unknown*
LINE 1: ... WHERE (plans.region_id = 1) AND (((plans.plan_no ILIKE '%44...
Can anyone enlighten me on how to work those suggested casts into the
search process without resorting to preparing my own SQL statement? This
seems doubly difficult given that both fields are of different types, and I
never know whether someone is searching by plan_no or by clsr!
Many thanks,
Tim
--
You received this message because you are subscribed to the Google Groups "Hobo
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/hobousers.
For more options, visit https://groups.google.com/groups/opt_out.