On Feb 21, 11:11 am, Cyrus Dev <rails-mailing-l...@andreas-s.net>
wrote:
> thanks fred
>
> but in o/p
>
> when we use find method and print that object  it shows like that
>
> [#, #, #, #]

That's probably because of exactly what I said. the default to_s/
inspect produces output like #<ClassName: ...> but that's not legal
html so it displays as just #. If you want something useful to be
displayed that's up to you, eg <%= records.collect {|r| r.name}.join
(', ') %> (assuming what you wanted to display was the name attribute
of the records. If you want to display all the attributes you could
probably just call inspect on the attributes property of each of  your
records.

Fred


>
> but when i modify same array with some operations
>
> i got array like this
>
> [{"1"=>"75225", "2"=>"Sat"},{"1"=>"75225", "2"=>"Sat"}]
>
> now can I convert this as like above like active record type of array ?
>
>
>
> Frederick Cheung wrote:
> > On Feb 21, 11:00 am, Cyrus Dev <rails-mailing-l...@andreas-s.net>
> > wrote:
> >> which contains array of hashes
>
> >> when we write simple find method of any tables it returns
>
> >> [#, #, #, #] in this way
>
> > Sounds like your view just contains <%= some_array %>
>
> > Which means that you'll just get the result of calling to_s on each of
> > your array elements, which is unlikely to be useful and also invalid
> > html since what it outputs is something like #<SomeObject:
> > 0x12345678> . It is up to you to produce some meaningful textual
> > output for your array elements (eg <%= h some_array.inspect %> but
> > even that is pretty crude)
>
> > Fred
>
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to