I'm working with a Struct that I mapped from a raw sql query for a
report. I finally get the search page to work and display my results,
however the view when rendered not only displays the expected output;
it also shows the Struct as it would look in the rails console!
my view is as follows:
<%=form_tag request.path,:method=>'get' do%>
<%=select_tag
'advisors',options_from_collection_for_select(@advisors,"id","full_name")
%>
<%=submit_tag "Search",:name=>nil%>
<%end%>
<div id="list">
<%=@assigned_students.each do |student| %>
<%= render :partial => 'assigned_student',:collection=>student %>
<%end%>
</div>
The partial is as follows:
<%if @assigned_students.kind_of?(Array)%>
<%=@assigned_students.each do |f|%>
<p><%=f.student_name%></p>
<p><%=f.advisor%></p>
<p><%=f.semester%></p>
<%end%>
<%else%>
<p><%=@assigned_students.student_name%></p>
<p><%=@assigned_students.advisor%> </p>
<p><%=@assigned_students.semester%>> </p>
<%end%>
The relevant controller code is as follows: (I've removed the sql
query string itself for readability.)
AdvisorList=Struct.new(:student_name,:advisor,:semester)
def advisor_list
@advisors=Advisors.all
#get_results
respond_to do |format|
format.html
unless params[:advisors].nil?
#long query removed from here
@assigned_students=query.map{|m|AdvisorList.new(m["Student
Name"],m["Advisor"],m["Semester"])
}
format.html
end #end respond_to
end #ends unless
end # ends method
Does anyone here understand what could be the problem?
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.