hyphen on columns name.. help.

I have a issue that I can't seen to fix.. I search all over.. and a lot about how to work with legacy *table* names but nothing about *column* names... this will not work because of the hyphen: @vcards = Vcard.find(:all, :select => "collection-owner")

this below will work but give me a lot of junk..!! @vcards = Vcard.find(:all, :select => "`collection-owner`")

as well this: @vcards = Vcard.find(:all, :select => "'collection-owner'")

but when I call this from a: <%= render :blablabla, :collection => @vcards %>

and in the _blablabla.rhtml <tr class="<%= cycle('odd', 'even') -%>">   <td><b><%= @vcards -%></td> </tr>

I will just get ##### and more garbage.. same when I do with console

can anyone tell me how can I work with column names with "-" hyphens...??? this is frustrating me.. I loved rails but this is starting to annoy me.. because I understand that tables should be created such a way but there should be options to work with legacy tables and not only table names and indexes but also column names... I have not found anything so far and trust me I HAVE LOOK and I am not the best using Google but my last hope before I finish this project on PHP is this call.

HELP!

The #### is just ruby printing out an object reference.

it's not garbage. it's ruby's description of the object.

What you want is

<%= @vcards.to_yaml %> or something else that will render them in a
different way.

Most likely you'll ACTUALLY want to traverse all the elements of that
array (@vcards) and print out items from it

<% for item in @vcards -%> <%= item.name %> <% end -%>

assuming "name" is one of the attributes on your vcard object.

You need to learn to walk before you can run. You seem to be trying to
jump WAY into the deep end. Why not just build a simple small rails
app that you control first and then try for your legacy table one that
you're using?

Julian.

Learn Ruby on Rails! Check out the FREE VIDS (for a limited time)
VIDEO #4 coming soon! http://sensei.zenunit.com/

Julian Leviston wrote:

The #### is just ruby printing out an object reference.

it's not garbage. it's ruby's description of the object.

What you want is

<%= @vcards.to_yaml %> or something else that will render them in a
different way.

Most likely you'll ACTUALLY want to traverse all the elements of that
array (@vcards) and print out items from it

<% for item in @vcards -%> <%= item.name %> <% end -%>    Hi, hmm but I already know this.. my issue is not the way I do it.. (I try many ways) it just happen for me to have send the last way I was trying... the issue is the hyphen in the column name.. no matter what way I use as long I can't get rails to ignore the hyphen somehow or something is not going to work..

Write your own accessors: def owner    self[:"collection-owner"] end

Fred

Write your own accessors: def owner    self[:"collection-owner"] end

Thanks!!!! this is something I was looking for.. I am going to research the topic thank you.