:collection

Hi
I am calling the following from the problem controller
@problem=Problem.find(params[:id])
MailSendingProblem.send_mail_to_group_owner(group_id.to_i,@problem) and
inside the def send_mail_to_group_owner

ProblemMailer.deliver_to_send_mail_to_user(user.name,pemailaddress.email,problem)

 Now in the view to_send_mail_to_user.rhtml I have

Number : <%= @problem.number%>
Title : <%= @problem.title%>
Urgency : <%=h ProblemUrgency.find(@problem.problem_urgency_id).name
if [email protected]_urgency_id==nil?%>

Priority : <%=h
ProblemPriority.find(@problem.problem_priority_id).name if
[email protected]_priority_id==nil?%>

   I have heard about collection but not yet used.What I am asking

is that in the above Urgency and priority from the view the db is
queried directly…So can i avoid this and pass the data as collections
(I dont know I am right) from controller and access it in view so that
avoid direct querying of datbase from view ? Or if I conntinue with the
above is it wrong?

Thanks in advance
Sijo

On Sep 8, 7:10 am, Sijo Kg [email protected] wrote:

Title : <%= @problem.title%>
Urgency : <%=h ProblemUrgency.find(@problem.problem_urgency_id).name
if [email protected]_urgency_id==nil?%>

Priority : <%=h
ProblemPriority.find(@problem.problem_priority_id).name if
[email protected]_priority_id==nil?%>

Given the time you;ve been posting to this list you should really have
read about associations.
Give problem a problem_urgency (or even just urgency) association and
the lines above become things like

@problem.problem_urgency.name if @problem.problem_urgency

Not sure what collections have got to do with any of this.
Fred

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs