Two simple (I hope!) questions: Let''s say I have a column name with a space, like (Customer Name Price). How can I display the value of that column in a view? @whatever.Customer Name Price doesn''t work for obvious reasons... what''s the proper syntax to display that? Also, is it possible to inject another variable into a variable? For instance, I''m passing a column name as a parameter. so... @whatever.@columnname is what I''m going for, but I''m unsure of the proper syntax. Thanks.! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You can use humanize method to display the column name. I don''t know if any database will allow defining columns with space in the name. You can chain calls together. I don''t know what you mean by injecting a variable. On 10/23/06, Patrick <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Two simple (I hope!) questions: > > Let''s say I have a column name with a space, like (Customer Name Price). > How can I display the value of that column in a view? > > @whatever.Customer Name Price doesn''t work for obvious reasons... > what''s the proper syntax to display that? > > > > > Also, is it possible to inject another variable into a variable? For > instance, I''m passing a column name as a parameter. > > so... @whatever.@columnname is what I''m going for, but I''m unsure of the > proper syntax. > > Thanks.! > > > > > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> > so... @whatever.@columnname is what I''m going for, but I''m unsure of the > proper syntax. >i *think* what you mean is @whatever.send(@columnname) you might want to look it up but i think that is the syntax and proper method. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Rob Schultz wrote:>> >> so... @whatever.@columnname is what I''m going for, but I''m unsure of the >> proper syntax. >> > i *think* what you mean is @whatever.send(@columnname) you might want > to look it up but i think that is the syntax and proper method.Yup... thanks a lot, that''s perfect! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---