On Fri, Oct 10, 2008 at 5:06 AM, Nate Turnage <[EMAIL PROTECTED]> wrote:

> On Thu, Oct 9, 2008 at 9:38 PM, Nate Turnage <[EMAIL PROTECTED]> wrote:
>
> > Can somebody tell me what magical incantation I need to put in my
> > environment.rb to get the 2.2.2 will_paginate gem working?
> >
>
> Sorry for the noise. I just used the tar archive and it worked.
>
> It looks to me like I have set things up for data collection the way I want
> it to work, but now I have an issue with validation. At the top of the form
> in the "subscribe" tab on the newsletter page these tags are present:
>
> <r:newsletter:if_form_errors>
>  All fields are required
> </r:newsletter:if_form_errors>
>
> Can anybody tell me where in the various files in the extension a form
> built
> on that page runs it's validation checks? I have looked in every file,
> except the tests, for some clue as to what would make that tag visible, but
> I cannot find anything. There is no mention of it in the tags available for
> the page.
>
> Honestly, I cannot figure out which controller and model combo even
> processes the form. I can figure out how the admin side of the extension
> works (for the most part), including where the validation happens, but I
> don't understand how the info is validated and processed on the client
> facing side.


Take a look at the process method of the newsletter_page model


http://github.com/pilu/radiant-newsletter/tree/master/app/models/newsletter_page.rb#L43-81

This big method holds a lot of logic, which is sort of equivalent to what a
controller would normally do. The actual validations belong in the
newsletter_subscriber model:


http://github.com/pilu/radiant-newsletter/tree/master/app/models/newsletter_subscriber.rb

and these are triggered when the model is saved.

I don't have time to offer any more advice just now, but here is a tip: when
your finding your way around someone else's code, the debugger is your
friend. Check out this article:

    http://guides.rails.info/debugging/debugging_rails_applications.html

In short:

    sudo gem install ruby-debug

Add this line to your /config/environments/development.rb:

    require 'ruby-debug'

Then insert the line:

    debugger

at the top of the process action. Restart your development environment.
Submit the form, and the code should stop at the break point. You can step
through the rest of the action line by line, enter 'irb' and examine all the
variables in that context, etc.

Good luck.

Drew
_______________________________________________
Radiant mailing list
Post:   [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant

Reply via email to