Hi there,
I've been trying to figure out if/how the following is possible...
@books: array of books
@books.each do |book|
do stuff...
do stuff...
do stuff...
book["number_of_pages"] = 123 #this is supposed to "inject" the
key/value pair
end
I want to:
==========
-> "inject" the key 'number_of_pages' with the value '123' into the hash
"book" ("book" IS a hash, right?), for every book in @books
-> Then, show in the view: All "Number of pages": <%= @books.collect
{|b| [b.number_of_pages] } %>
It doesn't work like this... (-> "undefined method `number_of_pages' for
#<Book:0xb5c022bc>")
How can I solve it...?
Many thanks for your help!
Tom
--
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 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
-~----------~----~----~----~------~----~------~--~---