search for: average_price

Displaying 2 results from an estimated 2 matches for "average_price".

2006 Jun 09
3
using a variable as substitute for a method
...is obvious but I couldn''t find the answer in the Ruby/Rails docs. How do I use a variable as a substitute for a method/field, so that I can call the object with the variable that contains the method name. For example, say I have the object Product, that has methods Price, Last_Price, Average_Price. I want to be able to return the value of either of those three fields based on the user selection. Ie, user selection is stored in params[:foo], which I assign to variable field_to_show, and I want to be able to call: Product.field_to_show which should output Product.Price (if params[:foo] c...
2006 Jun 09
0
Re: Rails Digest, Vol 21, Issue 195
...d calls are just messages send to objects, so you can use the #send method to do that. In ActiveRecords''s case, there''s a special convenience method that should work: ar_instance[var] > > For example, say I have the object Product, that has methods Price, > Last_Price, Average_Price. > > I want to be able to return the value of either of those three fields > based on the user selection. Ie, user selection is stored in > params[:foo], which I assign to variable field_to_show, and I want to be > able to call: > > Product.field_to_show > > which should...