Rails – How to use if else statement in array?

user2101461

I'm integrating infusionsoft with our rails app and we can create contacts using their API using this call, and passing the data through an array...

Infusionsoft.contact_add_with_dup_check({'Email' => contact.email, 'FirstName' => (contact.name if contact.name.present?)}, 'Email')

However, I want to be able to post additional contact info to their API if the contact in our rails app has more data. Such as if name or city is present. My attempt at checking if contact.name is present returns an error.

How can I do an if else statement within the array?

Kinaan Khan Sherwani
contact_info = {'Email' => contact.email}
contact_info.merge!({'FirstName' => contact.name }) if contact.name.present?
Infusionsoft.contact_add_with_dup_check(contact_info, 'Email')

you can use a code same as in line#2 in case of city

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Rails – How to use if else statement in array?

From Dev

How to use AND/OR in if else PHP statement

From Dev

How to use AND/OR in if else PHP statement

From Dev

How to call a string array in a if/else statement in Javascript

From Dev

How to use espresso matcher as a condition for If else statement?

From Dev

how to use if-else statement in accessor?

From Dev

How to use if-else statement with function returns?

From Dev

How to use an if else statement in the middle of an echo

From Dev

How do you use an if/else statement with an ActionSheet?

From Dev

How to use else single line statement in Perl ?

From Dev

How to use multiple lines of code for an else statement?

From Dev

How to use a for loop with an if-else statement

From Dev

how to use if-else statement in accessor?

From Dev

How to use HTML in a Javascript if/else statement?

From Dev

How to use if/else statement in Selenium IDE

From Dev

How to use else statement in jade template?

From Dev

How to use if and else inside echo statement?

From Dev

how to use Array with if else statements?

From Dev

Can you use if-else statement inside braces for an array in Python?

From Dev

If else statement for array

From Dev

Rails single line if else statement

From Dev

Rails single line if else statement

From Dev

How to print array data without displaying any if else statement

From Dev

How to use if else statement in for loop for creating a new column?

From Dev

How to use IF ELSE statement in DataBinder.Eval in asp.net

From Dev

How to know if radio button with specific id is checked to use in if else statement

From Dev

How can I use shorthand if else statement in my js code

From Dev

How do I properly use an if then else statement with jQuery/javascript?

From Dev

How to use IF ELSE statement in DataBinder.Eval in asp.net

Related Related

  1. 1

    Rails – How to use if else statement in array?

  2. 2

    How to use AND/OR in if else PHP statement

  3. 3

    How to use AND/OR in if else PHP statement

  4. 4

    How to call a string array in a if/else statement in Javascript

  5. 5

    How to use espresso matcher as a condition for If else statement?

  6. 6

    how to use if-else statement in accessor?

  7. 7

    How to use if-else statement with function returns?

  8. 8

    How to use an if else statement in the middle of an echo

  9. 9

    How do you use an if/else statement with an ActionSheet?

  10. 10

    How to use else single line statement in Perl ?

  11. 11

    How to use multiple lines of code for an else statement?

  12. 12

    How to use a for loop with an if-else statement

  13. 13

    how to use if-else statement in accessor?

  14. 14

    How to use HTML in a Javascript if/else statement?

  15. 15

    How to use if/else statement in Selenium IDE

  16. 16

    How to use else statement in jade template?

  17. 17

    How to use if and else inside echo statement?

  18. 18

    how to use Array with if else statements?

  19. 19

    Can you use if-else statement inside braces for an array in Python?

  20. 20

    If else statement for array

  21. 21

    Rails single line if else statement

  22. 22

    Rails single line if else statement

  23. 23

    How to print array data without displaying any if else statement

  24. 24

    How to use if else statement in for loop for creating a new column?

  25. 25

    How to use IF ELSE statement in DataBinder.Eval in asp.net

  26. 26

    How to know if radio button with specific id is checked to use in if else statement

  27. 27

    How can I use shorthand if else statement in my js code

  28. 28

    How do I properly use an if then else statement with jQuery/javascript?

  29. 29

    How to use IF ELSE statement in DataBinder.Eval in asp.net

HotTag

Archive