The Great Gatsby
The Great Gatsby

Reputation: 9

syntax error, unexpected tCONSTANT

Can any one explain me what's my problem :

ActiveRecord::Base.connection.select_values('SELECT c.value FROM custom_values c,
time_entries p, custom_fields cf  where  c.customized_type = 'TimeEntry' 
and p.id = c.customized_id and c.custom_field_id = cf.id 
and cf.type = 'TimeEntryCustomField' and cf.name = 'Reference TS Client' 
and p.id = '+ log.user.id.to_s +' ;')

I get this error just for "c.customized_type". What can be the issue?

Upvotes: 0

Views: 2984

Answers (1)

secador de pelo
secador de pelo

Reputation: 699

You are closing the String with ' and semicolon , try this one:

ActiveRecord::Base.connection.select_values("SELECT c.value FROM custom_values c,
time_entries p, custom_fields cf  where  c.customized_type = 'TimeEntry' 
and p.id = c.customized_id and c.custom_field_id = cf.id 
and cf.type = 'TimeEntryCustomField' and cf.name = 'Reference TS Client' 
and p.id = ?", log.user.id.to_s)

Upvotes: 5

Related Questions