views:

35

answers:

2

I've just inherited a website built with Ruby on Rails. I have never used the language before.

One thing I wanted to know is about Gems - my host only supports a few. I figure a Gem is like a library with PHP - for example, the mysql library is compiled with most PHP packages.

So I was wondering, does the following short code sample require a Gem, or is it too succinct to know?

class EnquiryMailer < ActionMailer::Base
  def enquiry enquiry_details
    @enquiry = enquiry_details

    recipients '[email protected]'
    bcc ['[email protected]']
    from "#{@enquiry.email}"
    subject "Web Enquiry"

    sent_on Time.now
  end
end

Thanks

+2  A: 

ActionMailer is a gem, that depends on other gems. so, yes, it does.

Jed Schneider
What sort of gems does it depend on? Thanks.
alex
it is part of Rails. `gem install rails` will install all the dependencies needed. Also, realize that you can install gems at your user level, so you don't necessarily need the host to support every gem you need. You will need to modify your `$GEM_HOME` variable to point to the proper gem directory, but `~/.gem` is a good place. Finally many hosts may install what you need if you ask.
Jed Schneider
Also, you are right, gems are libraries of code, but they are also 'stand alone' software projects (You can use action mailer without using rails, for example). While not always implemented Gems can provide bindings to native languages, like C or java (as example, to communicate with mysql you need the c mysql gem or the java jdbc-mysql depending on if you are using MRI or jRuby), where the binaries need to be compiled and installed, instead of just adding the code to the lib directory. That is why the gems must be installed rather than just included.
Jed Schneider
+1  A: 

Jed is not wrong about it depending on the ActionMailer gem

However, ActionMailer is part of Rails, so if your host supports the Rails version that this application is in, you'll be fine.

That code snippet does not seem to depend on any gems that Rails doesn't itself provide, but as you can guess, it's hard to tell with such a limited sample

bjeanes
Thanks for your answer +1
alex