Advertisement

05.26.2008 at 09:30PM PDT, ID: 23433888
[x]
Attachment Details

Rails: Arrays and ActionView::Partials

Asked by renderbox in Ruby Scripting Language

Tags: Ruby

I am trying to pass an array that I have created into an ActionView::Partials render.  Is this the right approach or am I going in the wrong direction?  When I tried to use it I kept getting an error:

ActionView::TemplateError (undefined method `code' for #<Hash:0x1a205fc>)

I know it's not a method but how would I just use a simple array instead of a collection of objects?Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
@logList = Array.new
@logList << {:code => '1010', :desc=>"something", :stat=>"success"}
@logList << {:code => '2010', :desc=>"something else", :stat=>"success"}
 
render(:partial=>'newResult', :collection=> @logList)
 
 
#In my Partial I have this line:
 
<% newResult.code %>, <% newResult.desc %><br>
[+][-]05.26.2008 at 09:51PM PDT, ID: 21649413

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Ruby Scripting Language
Tags: Ruby
Sign Up Now!
Solution Provided By: wesgarrison
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628