activerecord issues with rails 3 postgresql

i have one query

@recommendations =‘,max(recommendations.count)’).

where(‘recommendations.skill= ?’,@key).

order(‘recommendations.company_id ASC’).


joins(‘JOIN recommendations ON = recommendations.company_id’)

when i run this query i got this error

PG::Error: ERROR: table name “recommendations” specified more than once

Why it shows like that?

Since you’re querying on the Recommendation model, there’s already a ‘FROM recommendations’ clause in the generated query. You probably meant ‘cnames’ in that joins call.

You’ll also run into Postgres’s rules about using ungrouped values in the SELECT part; the above query won’t be legal even with a correct join.

–Matt Jones