# New to ruby, Need help

**URL:** <https://www.ruby-forum.com/t/new-to-ruby-need-help/134407>\
**Category:** Rails\
**Created:** [April 10, 2008, 4:00pm UTC](https://www.ruby-forum.com/t/new-to-ruby-need-help/134407 "2008-04-10T16:00:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![drsharp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e9bcb4/32.png) [@drsharp](https://www.ruby-forum.com/u/drsharp)\
**Post date:** [April 10, 2008, 4:00pm UTC](https://www.ruby-forum.com/t/new-to-ruby-need-help/134407/1 "2008-04-10T16:00:05Z")

</div>

I’m attempting to make a simple program, just combine two images and  
output a .jpg file. Here’s what I have:

class PicController \< ApplicationController  
require ‘RMagick’  
def index  
im1 = Magick::Image.read(‘1.jpg’) {self.size = “81x81”}.first  
im2 = Magick::Image.read(‘2-1.jpg’).first  
result = im1.composite(im2, 0, 55, Magick::CenterGravity)  
result.write(‘pic.jpg’)  
end  
end

I’m really only familiar with Java, I’ve been researching Ruby for about  
a half an hour now and know…well I don’t know much. I particularly  
have no idea how to run programs outside of a desktop environment. I  
have the ability to install Ruby and Ruby on Rails programs on my  
website, but don’t know how to go about doing so or how I would go about  
calling the program.

So my question is, how does my code look? I eventually want to pass  
parameters to the program and construct an image accordingly. How  
should I go about installing this and calling it?

Sorry for being so vague, I tried my best.

---

<div class="post-metadata">

**Author:** ![drsharp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e9bcb4/32.png) [@drsharp](https://www.ruby-forum.com/u/drsharp)\
**Post date:** [April 11, 2008, 1:29am UTC](https://www.ruby-forum.com/t/new-to-ruby-need-help/134407/2 "2008-04-11T01:29:39Z")

</div>

Ended up using php. I’ll tackle ruby another day.

---

<div class="post-metadata">

**Author:** ![drsharp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e9bcb4/32.png) [@drsharp](https://www.ruby-forum.com/u/drsharp)\
**Post date:** [April 11, 2008, 10:49pm UTC](https://www.ruby-forum.com/t/new-to-ruby-need-help/134407/3 "2008-04-11T22:49:20Z")

</div>

Dan,

Ruby, as a language, is very elegant and easy to use… even easier,  
IMO, than Java and PHP.

But, if you just want to whip up a quick one-file script like thing  
and test it from a browser, PHP rocks. But that’s just because  
browsers, out of the box (these days) support .php files to be  
processed by PHP. Right now, you can’t do that (out of the box) with  
Ruby files. Eventually that’ll change. Eventually, you’ll be able to  
drop a .rb file into a web directory and have it parsed through Ruby  
just like you can drop a .php file and have it parsed by PHP.

Until then, if you wanna play, play with ruby. Not Ruby on Rails, but  
just ruby. Command-line and all. If you want to do some quick  
scripting from a web app perspective, PHP is probably the right way to  
go. If you want to try and build a simple app, though, including  
multiple interactions between the browser and server, then Rails is a  
very nice framework (although not the only one).

So, it’s really just a matter of waht you are trying to do.

What you have above is exactly the sort of thing Ruby is extremely  
easy and powerful to use. It woudl just be a ruby script, called by  
the command line. Plopping it into the Rails framework is overkill and  
probably confusing as you start out.

Don’t write off Ruby because of Rails.

And don’t write of Rails, just recognize what it is: a framework using  
ruby.

-Danimal

BTW, I’m a hard-core RoR evangelist, but I also still use PHP in my  
day-to-day development work. Super-simple example: client wants an  
“about us” page that has the copyright at the bottom automatically  
show the current year. Perfect example of PHP. It’s effectively a  
static HTML page with a single line of PHP at the bottom. Stuff like  
that, where the extra “weight” of the full Rails stack isn’t warranted  
is where PHP is still useful. Eventually, though, I look forward to  
the day when I can just drop .rb files in and get the same effect.  
Woo! (For all I know, this is already possible. But not ‘out of the  
box’ on standard hosting environments)

On Apr 10, 5:29 pm, Dan S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![drsharp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e9bcb4/32.png) [@drsharp](https://www.ruby-forum.com/u/drsharp)\
**Post date:** [April 11, 2008, 11:03pm UTC](https://www.ruby-forum.com/t/new-to-ruby-need-help/134407/4 "2008-04-11T23:03:24Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Danimal wrote:  
| Dan,  
|  
| Ruby, as a language, is very elegant and easy to use… even easier,  
| IMO, than Java and PHP.  
|  
| But, if you just want to whip up a quick one-file script like thing  
| and test it from a browser, PHP rocks. But that’s just because  
| browsers, out of the box (these days) support .php files to be  
| processed by PHP. Right now, you can’t do that (out of the box) with  
| Ruby files. Eventually that’ll change. Eventually, you’ll be able to  
| drop a .rb file into a web directory and have it parsed through Ruby  
| just like you can drop a .php file and have it parsed by PHP.

Err, the only scripting languages support out of the box is JavaScript.

PHP and Ruby are server-side languages (where PHP is still a tad easier  
to setup than Ruby, and Ruby on Rails).

* * *

Phillip G.  
Twitter: [twitter.com/cynicalryan](http://twitter.com/cynicalryan)

Rule of Open-Source Programming #48:

The number of items on a project’s to-do list always grows or remains  
constant.  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.8 (MingW32)  
Comment: Using GnuPG with Mozilla - [http://enigmail.mozdev.org](http://enigmail.mozdev.org)

iEYEARECAAYFAkf/0fQACgkQbtAgaoJTgL+jGQCeLfs+yQTarUJe3+m81qk0dMAq  
TzQAnRTWeQFNQ6eazDlUXwHn014Xvz7W  
=atXD  
-----END PGP SIGNATURE-----
