Arquivo para 'Rails'

Deploying your Rails 3 app on Dreamhost

This is another quick post: to deploy your Rails 3 app on a shared hosting at Dreamhost, just use RVM to make sure your gems will have their place in the sun on the user’s directory (otherwise Passenger will throw an access denied to /root/.gems error) and then configure your Rails app for the new gems path. Here is the step-by-step:

1) Access your Dreamhost account via SSH.
2) Install RVM “as a user” (you won’t be able to try this as root). Here is the step-by-step).
3) Configure your app so Passenger will know where to find your gems, including these lines in config.ru at the beginning of the file:

ENV['GEM_HOME'] = '/path/to/your/gems'
require 'rubygems'
Gem.clear_paths

Where ‘/path/to/your/gems’ should be replaced by your GEM_HOME using RVM. Lets say you installed ruby 1.8.7 (using rvm install 1.8.7) and a gemset named mygemset, the path to your gems may look something like: /home/USER/.rvm/gems/ruby-1.8.7-p330@mygemset

Edit @ mar 6th, 2011: Yesterday, Dreamhost announced they already support Rails 3, and its current version at the time of this writing is 3.0.3

Fixing problems with Rails, RVM, openssl, and readline on Ubuntu

When you start working with RVM on Ubuntu, probably you’ll face some configuration problems while trying to execute script/console (Rails 2.x), e.g.:

no such file to load -- readline (LoadError)

or even

no such file to load -- openssl (LoadError)

The oficial RVM website offers one solution, but this may not apply for all situations.

To fix that problem, you’ll need to do the following:

1) Install openssl and readline libraries via apt:

$ sudo apt-get install libreadline6 libreadline6-dev openssl libssl0.9.8 libssl-dev libopenssl-ruby

2) Reinstal your ruby version using RVM, specifying readline and openssl directories:

$ cd <path to your Rails project>
$ rvm remove 1.8.7
$ rvm install 1.8.7 --with-readline-dir=/usr/include/readline/ --with-openssl-dir=/usr/include/openssl/

This example works with Ruby version 1.8.7 on Ubuntu 10. Make the proper changes to meet your environment. I’ve tested this solution with Rails 2.3.10 – I believe it will work with other versions/evironments as well.

Worked with you in another configuration? Just drop a line in the comments bellow and let me know!

Installing your Rails/RestfulX app (and its gems) at Dreamhost

Although I heard a lot of bad comments about Dreamhost, I cannot complain: in one year of hosting I had no problems.

Some days ago I published a tiny Flex/Rails/RestfulX app and it was straightforward. I had minor problems understanding how the user could install their gems, but it is really simple.

First create a subdomain with Passenger support. You’ll need to inform a web directory ending with “/public/”, as this screenshot shows:


Leia o restante do artigo

CRUD with RestfulX: Part 2/2 – Create, Update, and Delete

In my last article about CRUD with RestfulX I wrote about how to retrieve data from the Rails backend. In this article I’ll show you how the other CRUD operations (create, update, and delete) works with RestfulX.

I’ll keep using the same project as example and explore the same concepts too. It would be useful if you read my last post about how to retrieve data from the Rails backend with RestfulX.

Leia o restante do artigo

CRUD with RestfulX: Part 1/2 – Retrieve

Lets create an example to show how to use basic database operations (aka CRUD – Create, Retrieve, Update, and Delete) with RestfulX.

The project is pretty simple and will evolve as I write future articles using this example: an application to control events and people that attend to these events.

Leia o restante do artigo

“Advanced” installation of RestfulX into your Rails app

After you create your Rails project using rails , you can configure it to use RestfulX using the command script/generate rx_config. This command creates all the configuration files and downloads the RestfulX library file (restfulx_framework.1.2.4.swc, the current version while I write this post).

Alternatively you can also download the sorce of the restfulx_framework project and include it in your Flex project. To do so, use git to download the source: git clone git://github.com/dima/restfulx_framework.git. Now you shoud create the configuration files using this command: script/generate rx_config --skip-framework. The --skip-framework tells the rx_config command to generate the config files without trying to hit the server to download the framewokr library.

Leia o restante do artigo

Introduction to RestfulX

Although I still wrote two posts about that (a screencast and a tutorial), this article is the first of a series of articles I pretend to write about RestfulX, an incredible framework to integrate Flex (or AIR) with RubyOnRails, Google App Engine, CouchDB, SQLite or even with Juggernaut (a Rails plugin to push messages from the server to the client). In the very first posts I’ll focus on the integration between Flex and Rails. This will be a kind of “conceptual” post, but is as important as the “practical” ones.

The main idea behind RestfulX is to bring to Flex some of the development principles of rails, using a REST based communication. For example, if we define a model named Project that has many Tasks, we could do this on the Rails side:

@project = Project.new
@task = Task.new
@task.project = @project
@project.tasks.size          # The result is 1

And the RestfulX framework brings all these concepts to Flex (through ActionScript):

var proj:Project = new Project;
var task:Task = new Task;
task.project = proj;
proj.tasks.length;       // The result is 1


Leia o restante do artigo

(Português) Criando XML no Rails com caracteres acentuados

Sorry, this entry is only available in Português.

(Português) RestfulX – Introdução, instalação, configuração e primera aplicação em 5 minutos

Sorry, this entry is only available in Português.

(Português) Precedência dos operadores em Ruby

Sorry, this entry is only available in Português.