Re: [rspec-users] RSpec get model attribute values by name

2009-01-31 Thread Pat Maddox
On Sat, Jan 31, 2009 at 6:18 AM, James Byrne wrote: > Pat Maddox wrote: > >> I realize you didn't ask for all of that but I'm feeling a bit chatty. >> >> Pat > > The more information the better. I never really did understand exactly > what using eval() was supposed to accomplish, now I do. Chat a

Re: [rspec-users] RSpec get model attribute values by name

2009-01-31 Thread James Byrne
Pat Maddox wrote: > I realize you didn't ask for all of that but I'm feeling a bit chatty. > > Pat The more information the better. I never really did understand exactly what using eval() was supposed to accomplish, now I do. Chat away... I do want to point out that this is what the ActiveRec

Re: [rspec-users] RSpec get model attribute values by name

2009-01-30 Thread Pat Maddox
On Fri, Jan 30, 2009 at 3:56 PM, James Byrne wrote: > Zach Dennis wrote: > >> >> m = MyModel.new :name => "foo" >> m["name"] # => "foo" >> >> http://www.railsbrain.com/api/rails-2.2.2/doc/index.html?a=M001972&name=[] >> >> On a different note, how about some better variable names? > > That co

Re: [rspec-users] RSpec get model attribute values by name

2009-01-30 Thread James Byrne
Zach Dennis wrote: > > m = MyModel.new :name => "foo" > m["name"] # => "foo" > > http://www.railsbrain.com/api/rails-2.2.2/doc/index.html?a=M001972&name=[] > > On a different note, how about some better variable names? That code was for demonstration purposes for this question only. -- P

Re: [rspec-users] RSpec get model attribute values by name

2009-01-30 Thread James Byrne
James Byrne wrote: > This is a request for a programming technique: Got it... t1.read_attribute(column) -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users

Re: [rspec-users] RSpec get model attribute values by name

2009-01-30 Thread Zach Dennis
On Fri, Jan 30, 2009 at 3:45 PM, James Byrne wrote: > This is a request for a programming technique: > > Given > > class Mymodel < ActiveRecord::Base > end > > my_instance = Mymodel.new > > If I am given a string representation of an attribute "xxx" what is the > most elegant way of passing that s

[rspec-users] RSpec get model attribute values by name

2009-01-30 Thread James Byrne
This is a request for a programming technique: Given class Mymodel < ActiveRecord::Base end my_instance = Mymodel.new If I am given a string representation of an attribute "xxx" what is the most elegant way of passing that string to my_instance to retrieve its value? This is probably a common