Category: ruby

Aptana Studio RedRails Error

I was curious to try an IDE on Osx for Rails development and APTANA STUDIO seems to be the right product. (I do use TextMate as editor)

Aptana Studio is fully installed on my laptop but, when I try to install the RedRails plugin, it returns this error:

Requested operation cannot be performed because it would invalidate the current configuration. See details for more information.


Ruby Mylyn Connector Feature (Optional) (0.9.3.6479) requires feature
"org.eclipse.mylyn.context_feature (2.0.0.v20070628-1000)", or later version.

The solution: http://support.aptana.com/issues/browse/ROR-156

The most important steps are:

  1. Went to Help=>Updates=>Find and Install. Installed three Eclipse updates that the system found. Installation of updates worked ok.
  2. When the update window appears with RadRails updates, expand the tree and uncheck the box next to the Ruby Mylyn Connector Feature. This is an optional extension for users of Mylyn. You don’t need it, so you can safely uncheck the box and install.

This seems to works either on Windows, Osx and Linux

Aptana Studio RedRails Error

gem install mysql on linux

It might be a problem, an “old” well-known issue…

sudo gem install mysql

might return an error like:

ERROR:  While executing gem ... (Gem::Installer::ExtensionBuildError)
    ERROR: Failed to build gem native extension.

Well, this is cause you need the -dev environment of mysql. Too easy to think that it could be mysql-dev, no! just try

apt-get install libmysqlclient15-dev

It will works!

gem install mysql on linux

SQLite in Ruby on Rails su OSX

Oggi il mio primo esperimento con SQLite su un progetto rails. Va oremesso che spulciando documentazione ho visto che SQLite sarà integrato come database di default per rails mettendo mysql come scelta opzionale.
Per prima cosa è necessario installare la gemma sqlite3

 sudo gem install sqlite3-ruby

Poi si deve configurare il proprio file database.yml

development:
  adapter: sqlite3
  dbfile: dev.db
test:
  adapter: sqlite
  dbfile: test.db
production:
  adapter: sqlite
  dbfile: prod.db

A questo punto basta sotto lib/task/ un rake db.rake tipo questo:

namespace :db do
  desc 'Inserire i dati default'
  task :install => [:environment, 'db:migrate'] do |t|
    sDbPath = "#{ ENV['RAILS_ROOT'] }/db"
    h = YAML.load_file("#{ ENV['RAILS_ROOT'] }/config/database.yml")
    hConnection = h[ENV['RAILS_ENV']]
     puts "-----"
     puts "eseguo sqlite3 ..."
    `sqlite3 -echo '#{ sDbPath }/#{ hConnection['dbfile'] }' < '#{ sDbPath }/i_miei_dati.sql'`
  end
end

Semplice, efficace, veloce!

SQLite in Ruby on Rails su OSX

uninitialized constant ActionMailer

Sto programmando un sito multilingua che invia delle emial personalizzate. Per fare questo uso ActionMailer::Base.

All’interno del view che risiede sotto app/views/notifier/mia_view.rhtml avevo necessità di inserire delle costanti definite in una libreria. Ho perso un po’ di neuroni dietro ad un problema di uninitialized constant per cui ho anche creduto che sotto Notifier non fossero visibili… invece è più semplice del previsto: basta mettere dentro environment.rb la funzione di inizializzazione di action mailer (  ActionMailer::Base.smtp_settings = {} ) alla fine del document, dopo l’inizializzazioen di rails (Rails::Initializer.run do |config|)

E tutto è disponibile.

January 25, 2008
uninitialized constant ActionMailer

Rails: dynamic constant assignment

I’ve got an error  yesterday night that made me loose some time…

<% @myObjects.each{|T| -%>
    <div><%= T.name %></div>
<% end -%>

This returns a compile error “dynamic constant assignment”
I disovered that Rails does expect lowercase names attributes so my T was incorrect

Same code lowercase does works…

<% @myObjects.each{|t| -%>
	<div><%= t.name %></div>
 <% end -%>
January 19, 2008
Rails: dynamic constant assignment