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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I''ve had this before, too. But not so recently that I readily remember what was wrong. Cobwebs suggest it was not much more than a syntax error. In your controller you have a close brace but no open brace, which causes my eye to notice that you also have two format.html calls. Is there something else missing, or could that be the issue? On May 22, 2011, at 9:33 PM, Kevin wrote:> 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 23 May 2011 05:33, Kevin <darkintent-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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!Try removing stuff from your view until the unexpected output disappears, then you will know which line of code is showing the unwanted output. I hope you are using a Source Control System such as git so that you can easily get back to where you started. Colin -- 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. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 23 May 2011 05:33, Kevin <darkintent-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> <%if @assigned_students.kind_of?(Array)%> > <%=@assigned_students.each do |f|%>Take the "=" out of the front of the .each call. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Removing the entire loop from the calling view seems to have solved the issue. Thanks everyone. @Jim I was trying to have the partial render on the same page that the search was being done on to see whether the output was different on that page. That code is such a dirty hack as it stands right now. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.