On 09/05/2009, at 9:58 PM, Alberto Santini <[email protected] 
 > wrote:

>
> 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:
>

Hi. This whole email is really confusing. I suggest you try to send it  
again, but constrain yourself to being very simple and using half the  
length. Explain every step!

Blog: http://random8.zenunit.com/
Learn: http://sensei.zenunit.com/
Twitter: http://twitter.com/random8r

> 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to