Ruby on Rails Monday, April 18, 2016



On Monday, April 18, 2016 at 12:13:37 PM UTC-4, bot Peña wrote:
On Mon, Apr 18, 2016 at 10:50 PM, fugee ohu <fuge...@gmail.com> wrote:
>   def move_file
>     from_path=params[:file_name]
>     to_path=params[:file_name]
>     to_path["queue/"]=""
>     FileUtils.mv "#{from_path}", "#{to_path}"
>     redirect_to request.referrer
>   end
>

params[:file_name], from_path, and to_path all  point to the same
object. to verify, check their #object_id.

so if you modify to_path, you also modify the other two. try #dup to
copy an object.

kind regards
--botp

got it working using dup ~ thanks, fugee

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/07936890-294b-435e-a2fa-e1ef6dc609be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment