On Thu, Feb 10, 2011 at 9:33 AM, Brian Candler <b.candler / pobox.com> wrote:
> Mike Onofrietto wrote in post #980715:
>> However I've had very good results with attr_accessor.
>> Please help.
>
> You only defined reader methods. You also need:
>
>  >  >  
>   >  >  
> .. etc
>
> 'attr_accessor' gives you both reader and writer methods. 'attr_reader'
> gives you just the reader ones (as in your code), and 'attr_writer'
> gives just the writer ones.
>
> In future, it would be very helpful if you could post the exact error
> message you see. In your case it was probably something like
> NoMethodError - unknown method 'artist=', which would have immediately
> pinpointed the error.

I believe he did not get an error message but an empty (nil) output
(other than he wrote):

Ruby version 1.9.2
irb(main):001:0> class Song; end
=> nil
irb(main):002:0> s = Song.new("Bicylops", "Fleck", 260)
=> #<Song:0x10195a40>
irb(main):003:0> s.instance_variables
=> []

At least that would have been the case with the code he pasted.

Mike, your pasted code and output do not match.  Also the code that
you referenced is not the one in the attachment.  Please make sure you
report the real code and the real issue.

Cheers

robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/