rails 2D array access in Helper method

leo nike
Fri, 01 Nov 2013 14:20:32 -0000

Hi, I Want to simply print out 2d array elements. Method is located in
Helper module. Calling helper method from jQuery. At the moment I''m not
getting output (=> 0..3) I tried to do iterate through array via .each()
method, but it would just print en entire array, however i want to
access each element and convert it either to string or integer. can
someone point me to possible solution? thanks!

       #app/helpers/controller_helper.rb
           def get_array
              database = SQLite3::Database.open("test.db")
              result = database.execute("select * from table1")
              print_array(result)
           end

           def print_array(array)
             for i in 0..array.length
                  puts array[i][i]
             end
           end

      -------------------------------------------------------------------
     #app/views/controller/file.js.erb
       if($(''.check_box1'').is('':checked'')){
            $("#div2").html("<%= get_array%>")
       }

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit