0

I'm using the databasedotcom gem to sync my app with salesforce, it pulls a list of all accounts perfectly, but I need to have a primary contact for each account, I currently have this:

<p>
    <b>License Contact:</b>
    <%= Account.contact(@customer.Id).Name %>
</p>

<p>
    <b>Email:</b>
    <%= Account.contact(@customer.Id).Email %>
</p>

<p>
    <b>Phone:</b>
    <%= Account.contact(@customer.Id).Phone %>
</p>

and @customer is defined in my controller as @customer = Account.find(params[:id])

Carla Dessi
  • 9,086
  • 9
  • 39
  • 53

2 Answers2

1

Had a look at this link : http://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_SOQL_variables.htm

Which shows a few parameters and how to call them, I updated my code to this:

@contact = Contact.find_by_AccountID(params[:id])

Then called it in my view: <%= @contact.Name %> etc.

Carla Dessi
  • 9,086
  • 9
  • 39
  • 53
0

You can create individual objects in your controller and Call them istead. Example

@customer_name = Account.find(params[:id]).name
@customer_email = Account.find(params[:id]).email

and in the views you just need to call those objects.

    <p>
      <b>License Contact:</b>
      <%= @customer_name %>
   </p>

Hope this might help's.

Arihant Godha
  • 2,339
  • 2
  • 26
  • 50
  • I don't need the account name and email, I need the contact name and email for each account, which is why i'm finding it difficult. – Carla Dessi Dec 03 '13 at 11:48