Ruby on Rails Monday, April 18, 2016

On Mon, Apr 18, 2016 at 10:50 PM, fugee ohu <fugee279@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

--
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/CAAwHHQi9chVXUSNWbbn5dWESct1XyfMKVgvUEf7wTsPr3gjeWw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment