sinatra - Access Ruby accessors using block variables -
I have an application that I am using an active record to access a database. I am trying to get information and put it in a hash for later use.
Here's what I am doing basically.
is required 'active_support' @emailhash = hash.new email = email.find (all) email. Email | Email | Email.attributes.keys.each do | @column | | @EMailhash [email.ticketno] || Hash.new @ melehash [email.ticketno] = email @ End of the column end
The row that does not work:
@emailhash [Email.ticketno] = Email @ Column
Is there a way that I can do it properly? Basically my goal is to make a hash off values stored in the table column, any input is appreciated.
Object.send
. @emailhash [email.ticketno] || Hash New
does nothing. Something like this can happen:
is required 'active_support' @emailhash = {} Email.find (: all) .each do | Email | @mailhash [email.ticketno] = {} email.attributes.keys.each do | Key | @EMailhash [email.ticketno] [key] = "email.send" end of end
key "send", which calls the method identified by string or symbol is. / P>
Comments
Post a Comment