Setting up Apache2 and passenger for Ruby 2.0.0 is actually pretty simple. As of right now, for Passenger to work with Apache2 and Ruby 2.0.0 you will need to install Passenger 4 RC4 or above, which currently isn’t (technically) a stable release. I have found it’s pretty stable though.
Install passenger through RubyGems
First, install passenger through gems:
gem install passenger --pre
RVM or Ruby Verion Management is a library written for managing multiple version of Ruby on a single machine, and even for a single user. Using this set of libraries you can easily install a version of Ruby and switch between different version as and when you see fit. This is great for developers, especially those having to maintain multiple different applications, using different Ruby and potentially rails versions.
Installation of RVM on Ubuntu 12.04 for a single user
To start, download RVM and automatically install the latest stable version of Ruby
curl -L https://get.rvm.io | bash -s stable --ruby
Here we download a file which has a series of commands for installing RVM and the latest stable version of Ruby. `-s` tells bash to read commands from the standard input, which is the downloaded file from the rvm website. This process will take a while, depending on your connection speed and processors as it downloads and compiles Ruby and Rubygems. Continue reading
God is a very powerful process monitoring library written in Ruby. This tutorial describes how to setup a basic monitoring configuration file for a NodeJS application, telling God to restart the NodeJS app upon the process being killed (for what ever reason).
To get started, create a god/ directory within your Node app.
In this directory, create a god configuration file
Update the global God configuration file (Refer to previous tutorial on installing God on Ubuntu 12.04) with the location of your Node app config.
Great, when you reload God it will start using the configuration, but first we must write the configuration file. Open your nodeapp.god config file for editing. We will start off by creating a basic configuration file that will allow you to:
- Start node
- Stop node
- Restart node
God, a monitoring framework written in Ruby is easy to configure, easy to extend and easy to use. God allows you to monitor the state of a process (whether it is running or not) and perform specific tasks dependent upon the state. These tasks can be as simple as restarting the process or go as far as alerting you via email, text, a phone call – basically, anything you can programmatically do in Ruby.
This tutorial shows you how to setup God on Ubuntu 12.04 (and I’m pretty sure it would work for earlier versions of Ubuntu too). I will cover the installation and layout of configuration files, as well as setting up an init service script allowing for God to be started|stopped|restarted easily, and automatically started at boot. Continue reading
In a model I needed to modify a getter to append a string if a certain attribute evaluated to true. This works great, until I needed to detect the uniqueness of the attribute against a column in the DB through the :uniqueness validator.
new_value = read_attribute(:label)
if self.something == true
new_label += 'Str'
When validating against the label’s uniqueness the validator will read the label attribute from my custom getter, thus, if a record in the DB has a label of ‘Test’, and our new record has a label of ‘Test’ and self.something evaluates to true, the validator will get ‘TestStr’ from the getter and compare the custom value against the DB. Based on this setup, no match would be found. Continue reading