# Issue with hyphen

**URL:** <https://www.ruby-forum.com/t/issue-with-hyphen/138229>\
**Category:** Rails\
**Created:** [May 21, 2008, 7:08am UTC](https://www.ruby-forum.com/t/issue-with-hyphen/138229 "2008-05-21T07:08:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 21, 2008, 7:08am UTC](https://www.ruby-forum.com/t/issue-with-hyphen/138229/1 "2008-05-21T07:08:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 21, 2008, 7:42am UTC](https://www.ruby-forum.com/t/issue-with-hyphen/138229/2 "2008-05-21T07:42:01Z")

</div>

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](http://workingwithrails.com/person/11030-ryan-bigg)

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 21, 2008, 8:27am UTC](https://www.ruby-forum.com/t/issue-with-hyphen/138229/3 "2008-05-21T08:27:42Z")

</div>

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
