Issue with hyphen

I have a column name that has a hyphen… not the table name but column
name…
I am calling something like:
@online = Status.find(:first, :conditions => {:status => ‘online’} )

first problem I notes using the IRB console
is to be able to get information out of the array I need to specify with
element
like
@online[0].status
this works… but I was hoping to just use @online.status
but anyways my problem is with hyphens…
I can’t do this:
@online[0].collection-owner
it just wont work I try with ‘’ “” and `` around it… as well with #{}
hehe just in case…

any suggestion? thanks.

any suggestion? thanks.

Change the column name’s hyphen to underscore.


Appreciated my help?
Recommend me on Working With Rails
http://workingwithrails.com/person/11030-ryan-bigg

On 21 May 2008, at 06:41, Ryan B. (Radar) wrote:

any suggestion? thanks.

Change the column name’s hyphen to underscore.

Or write your own accessors to read/write it

def collection_owner
self[‘collection-owner’]
end

and similarly add the writer method

Fred

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs