Rails PG::SyntaxError: ERROR Clarification -
i'm getting strange error. have customers , messages.... customers has_many messages.. , message belongs_to customer customer has phone column , message has to column. code below suppose take current customer id , grab phone column find messages match phone based on to column. update messages customer id.
i'm getting error don't see problem. can tell me i'm doing wrong? error triggered on each loop. tried inspect @foundmessage_all doesn't work.
pg::syntaxerror: error: syntax error @ or near "to" line 1: select "messages".* "messages" (to = '2081234567'... ^ : select "messages".* "messages" (to = '2081234567' )
customer/show.rb
@customer = customer.find(params[:id]) tempphone = @customer.phone @foundmessage_all = message.where('to = ? ', tempphone) if @foundmessage_all != nil @foundmessage_all.each |t| t.update_attribute(:customer_id, @customer.id) end else #other stuff end
change below statement:
@foundmessage_all = message.where(to: tempphone)
if doesn't solve issue, post full stack trace.
also should checking present?
on @foundmessage_all
instead of != nil
if @foundmessage_all.present?
Comments
Post a Comment