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! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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/ On 15/04/2008, at 2:28 PM, rek2 wrote:> > 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! > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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.. -- 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"=>"somename-omLZJFyqO6uzyMef1NM1DQ@public.gmane.org"}> 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 ;-) if it was not because of the incompatibility column name I will have no problem. Thanks.> > Learn Ruby on Rails! Check out the FREE VIDS (for a limited time) > VIDEO #4 coming soon! > http://sensei.zenunit.com/ > > > On 15/04/2008, at 2:28 PM, rek2 wrote: > > >> 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! >> >> >> >> >> > > > > > > >-- 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 http://www.binaryfreedom.info --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Apr 15, 8:00 am, rek2 <r...-zTjyZANo7oz3ktU1ABlop6HonnlKzd3f@public.gmane.org> 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 hyphenWrite your own accessors: def owner self[:"collection-owner"] end Fred --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> 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. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---