[Rails] Re: Actionmailer Help Needed
On Jul 30, 12:28 pm, Jenny Blunt <li...@ruby-forum.com> 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| %>
> <li> <%= task.title %> </li>
> <% 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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home