Wednesday, March 19th, 2008
Red Box progress indicator with active_scaffold_upload branch
Problem
You need to display a splash screen when uploading files to a Ruby on Rails application.
Solution
My model:
class Number < ActiveRecord::Base
file_column :intro
file_column :vmail
end
The steps I have followed.
Install redbox plugin from project path run:
./script/plugin install svn://rubyforge.org/var/svn/ambroseplugins/redbox
If files redbox.js, redbox.css and redbox_spinner.gif haven’t been copied over to the public folders copy them over manually [...]
No Comments » - Posted in ruby on rails by kosmas
Tuesday, February 26th, 2008
Ruby On Rails on CentOS 4.6
Problem
Installing Ruby on Rails on CentOS 4.6.
The yum install ruby installs an old version of Ruby 1.8.1, but you want 1.8.6
Solution
Based on a script from uberdose
The original post is here:
http://wp.uberdose.com/2007/07/15/ruby-on-rails-on-centos-45/
wget ftp://ftp.gnu.org/gnu/readline/readline-5.1.tar.gz
tar xvfz readline-5.1.tar.gz
cd readline-5.1
./configure –prefix=/usr/local
make
sudo make install
cd ..
wget [...]
No Comments » - Posted in ruby on rails by kosmas
Thursday, February 14th, 2008
Using older Capistrano version 1.x after upgrading to Capistrano 2.x
Problem
You have just upgraded your Capistrano installation to version 2.x, but you didn’t have time to convert your recipes to the newer version.
Solution
In order to be able to use your old recipes of Capistrano version 1.x after upgrading, you can use the following (assuming your version 1.x is 1.4.1):
cap _1.4.1_ deploy
or, if you have migrations [...]
No Comments » - Posted in ruby on rails by kosmas
Tuesday, December 18th, 2007
using authentication with acts_as_authenticated
Problem
You want to use the easiest authentication method, in order to add users/permissions to your application.
Solution
Install the act_as_authenticated plugin:
script/plugin install http://svn.techno-weenie.net/projects/plugins/acts_as_authenticated
Generate controllers, models and migration:
script/generate authenticated user account
Add necessary user foreign keys in appropriate tables (ie customer in xxx_create_users.rb), plus other fields you may want to use in your user table (ie role):
create table “users”, [...]
No Comments » - Posted in ruby on rails by kosmas
Monday, December 3rd, 2007
ArgumentError (3 elements of civil date are necessary)
Problem
On creating a default date on a model using the after create, and by using Model.date_field = ‘2007-01-01′ we get the error ArgumentError (3 elements of civil date are necessary)
Solution
The workaround is to use:
Model.date_field = Date.civil(2007,01,01)
No Comments » - Posted in ruby on rails by kosmas
Friday, November 30th, 2007
cap deploy_with_migrations default behaviour
Problem
When using cap deploy_with_migrations, the default behaviour is to deploy with the migrations in the production environment.
Solution
To change this behavior add:
set :rails_env, “development”
in your config/deploy.rb
No Comments » - Posted in ruby on rails by kosmas
Monday, November 26th, 2007
Keeping uploaded files between deployments
Problem
You are using file_column plugin (or maybe another plugin?), to upload files in your ruby on rails application. Because the files are big you don’t want to have a different copy stored in your subversion repository for each different deployment version. You want to keep a common folder with all your uploaded files, and use [...]
No Comments » - Posted in ruby on rails by kosmas
Friday, November 16th, 2007
Adding icons to ActiveScaffold’s actions
Problem
You want to replace the standard text descriptions in ActiveScaffold’s actions with your icons.
Solution
Create a file called active_scaffold_overrides.css in ror_project/public/stylesheets
Copy the css code from ror_project/vendor/plugins/active_scaffold/frontends/default/stylesheets/stylesheet.css and paste it in to the file created in the previous step.
Create a directory my_images in ror_project/public/images/activescaffold to hold your images.
Copy to the new directory the images you want to [...]
2 Comments » - Posted in ruby on rails by kosmas
Thursday, November 8th, 2007
Controller testing in Active Scaffold
Problem
You need to have to functionally test your controller when you are using ActiveScaffold. There are pieces of code that tell you how to do that on a normal ror application (ie without ActiveScaffold), like recipe 7.17 on the Rails Cookbook, or a fragment of code in an Active Scaffold application, but they don’t have [...]
2 Comments » - Posted in ruby on rails by kosmas
Monday, November 5th, 2007
:int and :integer problem in Ruby on Rails migration
After spending some time trying to make a migration work, and having the error message coming back:
You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.[]
I’ve decided to do a google search for the specific problem, as it was working fine with other [...]