databasedotcom error on no record found

99封情书 提交于 2019-12-23 04:56:12

问题


Just started using databasedotcom gem and now stuck.

When trying to find a record in Salesforce by Id, if the id/record doesn't exist, it produces the following error:

"Provided external ID field does not exist or is not accessible:"

If the Id does exist I am able to continue with my page fine.

Here's my code:

def search
@account = Account.find(params[:id])

if @account.Id
  redirect_to new_user_registration_path(:id => @account.Id)
elsif params[:id].to_s.present? and @account.nil?
  flash[:alert] = "Couldn't find that one.  Please check and re-submit your number."
  redirect_to search_path
end

end

How can I overcome this?

Thank you.


回答1:


Changed the code to the following and it works fine now - thank you Danny Burkes. It captures the exception and routes accordingly.

def search
begin
@account = Account.find(params[:id])

if @account.Id
  redirect_to new_user_registration_path(:id => @account.Id)
end
rescue Exception => e
  flash[:alert] = "Couldn't find that one.  Please check and re-submit your number."
  redirect_to search_path
end

end



来源:https://stackoverflow.com/questions/11976343/databasedotcom-error-on-no-record-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!