search for: field_to_show

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

2006 Jun 09
3
using a variable as substitute for a method
...t 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] contained ''Price'') Currently this gives a no method error. I know that I can do case params[:foo] when "Price" Product.Price etc but it seems to me...
2006 Jun 09
0
Re: Rails Digest, Vol 21, Issue 195
...t; > 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] contained ''Price'') > > Currently this gives a no method error. > > I know that I can do > case params[:foo] > when "Price&qu...