accessing a variable in the view

Now I've decided I want to access factor in my view...

but it's blank when i try <br>Factor: <%= @course.factor %>

How do I do it?

here's my model....

Now I've decided I want to access factor in my view...

but it's blank when i try <br>Factor: <%= @course.factor %>

Until the discounted_price method is called, @factor has no value.

You could pull the case statement that sets @factor into its own method and call that 'factor'. Then you can omit the attr_reader (since you defined the method yourself) and @course.factor will do what you originally expected.

-Rob

Rob Biedenharn http://agileconsultingllc.com
Rob@AgileConsultingLLC.com