Hi all!
I have a Place model with a description attribute and a Service model
with an itinerary attribute. An itinerary is simply a string with
dash-seprated place descriptions. In my services_controller.rb#create i
have the following code:
itinerary = params[:places].merge(params[:places]){|id, place_id|
Place.find(place_id).description}
Where params[:places] is a hash like
params[:places] #=> {"1" => "3", "2" => "4", "3" => "3"}
in the form
{:leg_number => :place_id}
I would like to receive a Hash like the following
itinerary #=> {"1" => "San Francisco", "2" => "Los Angeles", "3" => "San
Francisco"}
and I use the code above to achieve that.
The code works well in script/console, while it is not working in the
controller, producing the same params[:places] array, like if the block
is not excuted.
I mean, in my controller, if I put the above code or the following
itinerary = params[:places].merge(params[:places])
i get the same result:
itinerary #=> {"1" => "3", "2" => "4", "3" => "3"}
Where am I wrong? Any suggestion is appreciated :-)
Thanks in advance.
--
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---