views:

21

answers:

1

i got this error:

SQLite3::SQLException: no such column: apis.name: SELECT * FROM examples WHERE ("apis"."name" = 'deep') 

my code

 Api.find :all, :from => params[:table_name], :conditions => {:name => 'deep' }

I need to make a back end rails application which will be used by a silverlight application. one of the requirements is to fetch simple data from the database. i need to be able to query different tables with the same code.(my app has 2000 tables!)

i think it does not make sense for rails to put in "apis" in the WHERE clause. is there any speciic reason for this?

A: 

It does that so when joins are performed, the where clauses will line up with the right tables' columns. This is handy most of the time, but in your particular case causes issues.

What you could do is use the other conditions syntax, which will not add rails table names to the attributes, but still sanitize the inputs properly.

Api.find :all, :from => params[:table_name], :conditions => ['name = ?','deep']
BaroqueBobcat