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

<%= @vcards -%>

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 L. wrote:

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…

for item in @vcards
item.collection-owner
end

NoMethodError: undefined method `collection’

the hyphen is my issue.

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

the problem is that the attributes is the one with the hyphen…

item.attributes
=> {“collection-owner”=>“[email protected]”}

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.

LOL but then is boring :wink: if it was not because of the incompatibility
column name I will have no problem.

Thanks.

lot
@vcards = Vcard.find(:all, :select => “‘collection-owner’”)
same when I do with console
and trust me I HAVE LOOK and I am not the best using Google but my


A Spectre is haunting multinational capitalism–the spectre of free
information.
All the powers of ``globalism’’ have entered into an unholy alliance to
exorcize this spectre:
Microsoft and Disney, the World Trade Organization, the United States
Congress and the European Commission.
Eben Moglen from the FSF.
http://emoglen.law.columbia.edu/publications/dcm.html

Solidarity:
http://www.dailyradical.org
http://www.diarioradical.org
http://www.spboston.org

On Apr 15, 8:00 am, rek2 [email protected] wrote:

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

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.

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