It does seem like it should be straightforward, but there's a bunch of
complex logic that I dont want to put directly into views. Initially I
had it in a helper, then pulled it into the Reporter object I
mentioned, but then I got the problem I mentioned.

My latest has the logic in a Module. What I find interesting is that
when called from the views (pages), it works fine; but when called
from the mailer, I get the following:

        undefined method `player_url' for ReportHelper:Module

Here's some of the code in the module:

        module ReportHelper

        include ActionView::Helpers::UrlHelper
        include ActionController::UrlWriter
        include ActionView::Helpers::TagHelper

        def self.html_tracker_report(player, stat, updates, last_update,
for_email=false)
                output = []
                spacer = "   "

                if for_email
                        line = '<span style="font-weight: bold;">' + 
link_to(player.name,
player_url(player), :style => "color: #666; font-weight:bold; text-
decoration: none;") + '</span>' + spacer
                else
                        line = '<span class="playerName">' + 
link_to(player.name,
player_path(player))  +'</span>' + spacer
                end
         end

Note the includes and note the logic ("if for_email") that is set up
to separately deal with CSS issues in the email. It's slightly
different where the email part uses player_url vs player_path, but
I've tried both and still see problems in resolving the named route.

One more detail that might give a clue: The emails are generated from
a rake task (invoked by a cron job) rather than from some use action
on the site. I dont think that makes a difference, but, maybe...?

My guess is that I haven't included something... or maybe I'm not
calling link_to correctly for this case. But, I dont see it so any
help is appreciated.

On Mar 4, 6:04 am, Starr Horne <st...@chatspring.com> wrote:
> On Tue, 3 Mar 2009 20:56:47 -0800 (PST)
>
> lunaclaire <szager...@gmail.com> wrote:
> > I have a new service called redeyestats.com and the major function is
> > to send a daily email with a report (specifically a daily stats
> > listing for sports players that the user is following). This report
> > mirrors a page with the same info on the site.
>
> > I want to keep things DRY, so it seemed like a good idea to create a
> > Reporter class that would compile each player report for both cases of
> > a) compiling the email and b) the site's page listing. Each player
> > report has links in it to the player's page, their team page, and to a
> > game page for their latest game.
>
> This sounds like a pretty straightforward use case for ActionMailer. You can 
> add links to your email via actionmailer templates (via link_to). Then you 
> can use the regular controller/view mechanism for your pages.
>
> So in summary
> 1) Store all of your player data in the model
> 2) Use an actionmailer template for the email
> 3) Use normal views for the pages
>
> SH
> --
> Starr Horne
> My blog:http://starrhorne.com
> Check out my Helpdesk RailsKit:http://railskits.com/helpdesk/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to