FileUtils.mv

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

request parameters:

{“file_name”=>“recordings/WCR-20160409.mp3”,
“file_type”=>“to_be_moved”,
“page”=>“list_directory”}

i get this error:

Errno::ENOENT in RecordingsController#move_file No such file or
directory @
sys_fail2 - (recordings/WCR-20160409.mp3, recordings/WCR-20160409.mp3)

around … FileUtils.mv “#{from_path}”, “#{to_path}”

I’m trying to move the file from the recordings/queue/ direcotry up a
level
to recordings/ I don’t really understand the error it looks like it’s
taking both arguments, from_path and to_path and treating them as a
combined first argument Anyone?

On 18 April 2016 at 15:50, fugee ohu [email protected] wrote:

def move_file
from_path=params[:file_name]
to_path=params[:file_name]
to_path[“queue/”]=“”

Have you put a debug print in to check what from_path and to_path are
set to?

Colin

i get this error:

Errno::ENOENT in RecordingsController#move_file

No such file or directory @ sys_fail2 - (recordings/WCR-20160409.mp3,
recordings/WCR-20160409.mp3)

around … FileUtils.mv “#{from_path}”, “#{to_path}”

On Mon, Apr 18, 2016 at 10:50 PM, fugee ohu [email protected] 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

On Monday, April 18, 2016 at 11:32:07 AM UTC-4, Colin L. wrote:

“page”=>“list_directory”}

You received this message because you are subscribed to the Google

For more options, visit https://groups.google.com/d/optout.

No because this action doesn’t print, it moves the file and redirects

On Monday, April 18, 2016 at 12:13:37 PM UTC-4, bot Peña wrote:

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

the = assignment operator assigns the values from the right side operand
to
the left side, it doesn’t change the value of other variables, i dunno
what you mean and i dunno what #dup is ~ fugee

On 18 April 2016 at 19:07, fugee ohu [email protected] wrote:


how can changing to_path affect the value of from_path ?

Because, as botp pointed out, they are referencing (pointing to) the
same object in memory.
Use
to_path = some function of params[…]
to avoid the problem. In a previous post you said you did not know
what dup does. Perhaps you should find out.

Colin

On Monday, April 18, 2016 at 3:53:44 PM UTC-4, Colin L. wrote:

to avoid the problem. In a previous post you said you did not know
what dup does. Perhaps you should find out.

Colin

Like what inconsequential function of params[:file_name] could i use? i
tried params[:file_name].to_s but it had no affect

On Monday, April 18, 2016 at 11:32:07 AM UTC-4, Colin L. wrote:

“page”=>“list_directory”}

You received this message because you are subscribed to the Google

For more options, visit https://groups.google.com/d/optout.

how can changing to_path affect the value of from_path ?

On Monday, April 18, 2016 at 3:53:44 PM UTC-4, Colin L. wrote:

to avoid the problem. In a previous post you said you did not know
what dup does. Perhaps you should find out.

Colin

got it working using dup ~ thanks, fugee

On Monday, April 18, 2016 at 12:13:37 PM UTC-4, bot Peña wrote:

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