2

I am using Rails 4 and PHPmyadmin

I designed a form that sends an email with two links, let's call them Link #1 and Link #2.

I need to know if the user that received the email has clicked on link #1 or link #2.

I already have the landing view #1 and view #2 with their corresponding id's, and can access both links.

The end result is that in my list table I need to display the status of every email sent with either:

  • Pending (if user hasn't clicked on any link)
  • Link #1 (if user clicked on it)
  • Link #2 (if user clicked on it)

I know that I need to associate the email id with the view id, but don't know how to do this.

Something like this:

EMAIL.......... LINK CLICKED
me@example.com  pending
john@example.com  Link 1
sonia@example.com  Link 2

I have found this similar question and this other one, however I don't know how to implement it in my app.

Community
  • 1
  • 1
pochat
  • 33
  • 5
  • I don't know Ruby but check if there is a data structure like a HashMap where you can store "john@example.com" -> "1". Then your html would have: name="emailsMap['john@example.com']" – egallardo May 02 '14 at 05:29
  • Check this out too: http://stackoverflow.com/questions/1227571/how-to-iterate-over-a-hash-in-ruby – egallardo May 02 '14 at 05:31
  • Thanks for that link, it helped me to understand the process a bit. – pochat May 03 '14 at 17:24

1 Answers1

1

Each link relates to a method in the controller that renders the view.. in your case Link#1 and Link#2 will correspond to some specific action in some controller. You can place checks there against the user you have sent email. Please tell if this helps

noman tayyab
  • 355
  • 3
  • 14
  • Allright, so I did what you said and that worked! I created a controller and a method. Now I am able to save in the database the link id. Now I need to know how to retrieve it, all I'm getting on a link.inspect is the <8883922xhh220>. thanks a lot. – pochat May 03 '14 at 17:26
  • what are you storing and what do you want to retrieve? – noman tayyab May 27 '14 at 13:07