Getting rails console on an amazon aws server when using rvm

Problem

You would like to get access to your rails application console on an Amazon ec2 instance, and you are also using rvm.

Solution

  • Login with ssh to your server as normal:
    ssh name@myserver.com -i amazon_key
  • Go to your application’s current folder:
    cd /my/project/directory/current/
  • Run the following replacing the environment with your specific environment (ie production,beta,staging etc):
    bundle exec rails c environment

no such file to load — readline (LoadError) in Rails 3.0.7 – Mandriva 2011 64

Problem

When you try to run the console rails c in a new Rails 3.0.7 application, in Mandriva 2011 64bit, and when you use rvm, you get the following error:

no such file to load -- readline (LoadError)

Solution

Similar to an earlier post here, the solution is as follows with the new requirements described

It’s quite like likely that the readline libraries are missing from your installation. To find out which ones go to the directory that the error is indicating (ie):

cd ~/.rvm/src/ruby-1.9..2-head

and then to the following:

cd ext/readline

then run the following:

ruby extconf.rb

If you get something like:
checking for readline/readline.h... no
checking for editline/readline.h... no

then you are probably missing the neccessary header files for readline.
so install them in your system (ie in Mandriva):

sudo urpmi lib64readline-dev,

When the package is installed successfully run the following again:

ruby extconf.rb
make
sudo make install

You should now be able to go back to your project and run rails c with no errors.

no such file to load — pdfkit (LoadError)

Problem
You are trying to use the pdfkit (here) in your rails application, and you configure it according to the configuration options for the rails 2.x in the config/environment.rb file. Although the application works, when you are trying to use the console you get the error:

no such file to load -- pdfkit (LoadError)

Solution
Make sure that:

require 'pdfkit'
in the config/environment.rb file comes after the line:

require File.join(File.dirname(__FILE__), 'boot')

Testing Active_Mailer with GMail in development

Problem
You want to test your email configuration and be able to send emails in your development environment, using a GMail account in a Rails application using 2.3.2.

Solution
Start your console in your development environment:

./script/console

Add the following replacing your GMail details:


ActionMailer::Base.smtp_settings = {
:enable_starttls_auto => true,
:address => "smtp.gmail.com",
:port => 587,
:domain => "your_gmail_domain",
:authentication => :plain,
:user_name => "your_gmail_user_name",
:password => "your_gmail_password"}

Add a simple email class:


class MyMailer < ActionMailer::Base def test_email @recipients = "an_address_to_sent_to@domain.com" @from = "address_from@your_google_domain.com" @subject = "test from dev console" @body = "this is the body" end end

and to finally test the email:


MyMailer::deliver_test_email

if it doesn't return with an error but with something like:


TMail::Mail port=#TMail::StringPort:id=0x..fdab4cee0 bodyport=#TMail::StringPort:id=0x..fdab4a9ec

then it should be working so add the configuration to your environments/development.rb

config.action_mailer.smtp_settings { ... }