Forum: Radiant CMS Email/subscriber validation issues with subscriber_lists extension

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Nate T. (Guest)
on 2008-10-09 21:25
(Received via mailing list)
Hey guys,

I am using the subscriber lists extension (thanks nelstrom, I love the
CSV
export) for creating a "contact us" type of form. The problem is that
when
somebody signs up with an email address that is already in the db, the
information gets overwritten with the newly submitted data. I am not
exactly
sure how to add a check against the db to find out if an email address
is
already there, and then return an error message that tells the user so.
Can
anybody give me some pointers on how to add that into the form process
action?

Pastie with the action from the subscriber_list_page model:
http://pastie.org/288758

Mucho, mucho garcias.



~Nate
Andrew N. (Guest)
on 2008-10-10 01:55
(Received via mailing list)
On 9 Oct 2008, at 18:24, Nate T. wrote:

> Hey guys,
>
> I am using the subscriber lists extension (thanks nelstrom, I love
> the CSV
> export) for creating a "contact us" type of form.

I'm not sure if I understand you correctly, but "Contact us" is not
the use case I had in mind when I made the subscriber lists extension.
It is more appropriate for a "Sign up to our mailing list" type of
scenario. (Such as demonstrated here: http://westportbookfestival.org/)

If you want a "Contact us" form, I think the Mailer extension could be
a better fit.

  http://github.com/radiant/radiant-mailer-extension...


I'll answer the rest of your mail assuming that a "Sign up to our
mailing list" scenario is what you actually want...

The subscriber_list extension does not handle sending mail from the
server, so there is no verification step. (e.g. sending an email to
the submitted address, with an activation link.) If you need that
functionality, try out Andrea's newsletter extension:

  http://github.com/pilu/radiant-newsletter/tree/master

The subscriber list extension is basically a plagiarized newsletter
extension, with the mailing functionality removed. I couldn't get the
newsletter extension to send mail through a gmail account. Although I
would be willing to try again since I discovered this:

  http://github.com/caritos/action_mailer_tls/tree/master

> The problem is that when somebody signs up with an email address
> that is already in the db, the information gets overwritten with the
> newly submitted data.

If an email is submitted to the form, it is added to the list
immediately. Without verifying that the email address submitted
belongs to the person who submitted it,

Without a verification step, the case of one email being submitted
more than once is difficult. You could either:

* Add all details to the db each time they are submitted, regardless
of whether they have been submitted before or not (potentially leading
to duplicates)
* Check if an email has been added already, and ignore any form
submissions if the email address supplied is already in the db
* Check if an email is already in the db, and if it is, use the
details supplied in the form to update the details of the entry
already existing

I settled for the last of these, although none of them are really
satisfactory, because you don't know (without a verification step)
whether the person submitting the form is the true owner of the email
address.

Verification is clearly the best-practice, but as an extra step in the
procedure, it can be seen as a deterent. And so clients often prefer
to have a simple one-step signup, despite the problems it can cause.

> I am not exactly sure how to add a check against the db to find out
> if an email address is
> already there,

It already does this (line 9 in your pastie):

  @subscriber =
Subscriber.find_by_email_and_subscriber_list_id(parameters[:email],
self.id)

Here is the relevant section of code, annotated with comments:

  http://pastie.org/289009

That should help you out, if you want to modify the behaviour.

Cheers,
Drew
This topic is locked and can not be replied to.