Go Back   CodingForums.com > :: Server side development > Ruby & Ruby On Rails

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-12-2011, 01:44 PM   PM User | #1
roher4
New Coder

 
Join Date: Jul 2010
Location: Canada
Posts: 26
Thanks: 2
Thanked 0 Times in 0 Posts
roher4 is an unknown quantity at this point
Converting PHP to Rails

Hi,

How would I go about converting this PHP into RoR? I'm just starting out and am a little confused.

Here's the code I want to convert:
Code:
<?php  
$file_name = substr ( md5(uniqid(rand(),1)), 5, 15); 
$uploaddir = './uploads/';
$file = basename($_FILES['userfile']['name']);
$newname = $file_name . $file;
$uploadfile = $uploaddir . $newname;
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {        
$imagepath =  http://example.com/uploads/{$newname};
}
print $imagepath;?>
roher4 is offline   Reply With Quote
Old 03-29-2012, 11:20 AM   PM User | #2
novafist
New to the CF scene

 
Join Date: Mar 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
novafist is an unknown quantity at this point
Looks like a file upload, you can start by looking at the gems: carrier wave, paperclip.

I could teach you to do it manually, but your code will suck compared to theirs.
novafist is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:06 AM.


Advertisement
Log in to turn off these ads.