Thanks Rob But actually what I want to do here
I have hash @restaurant now for each row I want to add diffinmiles and then filter some of rows from main hash with this new column add and then sort this new array based on diffin miles thanks Rob Biedenharn wrote: > On Feb 19, 2009, at 6:20 AM, Cyrus Dev wrote: >> Hi, >> thanks >> >> but I have instance like this >> >> @restaurant= Restaurant.find(:all, > :select => 'restaurants.*, 22 AS diffinmiles' >> but this is not work >> >> so that i have to not change in view file and i can direct access like >> db values ? >> >> any idea ? > > Except that is not really what you meant, I'm sure. If you need some > other method to be available on the Restaurant model, just add it in! > > class Restaurant > def diffinmiles(my_location) > # do some calculations with other attributes and the passed > parameters > end > end > >>>> >>> If you want to change the array you are iterating over, that isn't >>> supported. >>> >>> Fred > > You're not actually changing the array here as Fred suggests, you're > just modifying each member which is perfectly fine (even though, as I > said, not what I think you really want to do here). > > -Rob > > Rob Biedenharn http://agileconsultingllc.com > r...@agileconsultingllc.com -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---