Re: Actionmailer Help Needed

Frederick Cheung
Sat, 30 Jul 2011 15:03:51 -0000

On Jul 30, 12:28 pm, Jenny Blunt
<li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>
wrote:
> Ok, I''m nearly there.
>
> Have figured out how to get actionmailer to email those users with tasks
> due. That was ok after I got my head around it.
>
> I can get the email view to list ALL tasks but not just those owned by a
> user. In my view, I''ve tried this:
>
> <% Task.tasksdue.find_each do |task| %>
> <%= task.title %>
> <% end %>
>
> Which calls a scope from my Task model.
>
Like i said before, if user is the user in question and the
association is called tasks then user.tasks.tasksdue is what you want.

>  scope :tasksdue, lambda {
>      where("dueddate >= ? AND user_id = ? AND status = ?",
Date.today,
> :user_id, false)
>   }
>
> But I don''t get any data out of that. If I get rid of the user_id
> aspect, it lists all tasks.
>
If you look at your log files you''d see that that is searching for
rows where the user_id is the string ''user_id''.
If you want to be able to pass parameters into a scope then you need
somelike like lambda {|parameter1, parameter2| ...} and you then to
Task.tasksdue(foo,bar)

Fred

> How can I adjust that so it works?
>
> Thanks
>
> Jx
>
> --
> Posted viahttp://www.ruby-forum.com/.

--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.