up

Blogs

how to install Ruby on rails webshop?

You have installed RoR3 and now you want to install a rails3 webshop.

I think the best solution is Spree. This is the only rails3 based e-commerce solution at this time.

How do you install this shop?

rails new rails3-shop
cd rails3-shop

edit Gemfile and add new line

gem 'spree'

Install new spree site.

rails g spree:site
rake spree:install
rake db:migrate
rake db:seed
rails server

The rails server command starts the webrick server. You should go to http://localhost:3000/ to check spree.

HTML number formatting with PHP

Here is my HTML number formatter. Sometimes the browsers wrap the numbers along thousand separator or decimal pont, but this function prevents this event.

function html_number_format($number, $decimals = 2, $dec_point = '.', $thousands_sep = ',') {
  if ($number === FALSE) {
    return '---';
  }
  return '<span style="white-space: nowrap;">'.number_format($number, $decimals, $dec_point, $thousands_sep).'</span>';
}

Deploy rack applciaton

Make config.ru with following content:

require 'rubygems'
require 'sinatra'
require './my_sinatra_application.rb'

run Sinatra::Application

You have to run bundle command. This will be install all necessary gems that listed in Gemfile.

You find debug log in default apache 2 error log files. This is /var/log/apache2/error.log in my case.

RMagick install on Ubuntu 10.10 and 10.04

This small tutorial work on Ubuntu Hardy (8.04), Lucid 10.04 and Maverick (10.10)

Install Imagemagick and GraphicsMagick

apt-get install imagemagick graphicsmagick

Install Image Magick development files

apt-get install libmagickcore-dev libmagickwand-dev
gem install rmagick

On Hardy:
Install imagemagick from source and after it install development files:

Blog categories:  Linux  Unix admin

How to use Padrino with mongodb

Padrino is a ruby framework built upon the excellent Sinatra Microframework.


$ padrino g project blog -d mongomapper -t rspec -s jquery -e haml -c compass
create
create config.ru
create public/favicon.ico
create config/apps.rb
create config/boot.rb
create app
create app/app.rb
create app/controllers
create app/helpers
create .components
create Gemfile
Applying 'mongomapper' (orm)...
apply orms/mongomapper
inject Gemfile

Blog categories:  Web development
Blog tags:  ruby  padrino

How to install Phusion Passenger for ruby 1.9.2

There are some easy steps to install Phusion Passenger for ruby 1.9.2 and apache2 on Ubuntu Linux.

1. Install rvm system wide

sudo bash < <( curl -L http://bit.ly/rvm-install-system-wide )

2. Install ruby 1.9.2

rvm install 1.9.2

3. add new line in /etc/bash.bashrc

[[ -s /usr/local/lib/rvm ]] && . /usr/local/lib/rvm

4. install passenger

sudo -i # you need root shell
rvm use 1.9.2-p0@global # or your version, use: rvm list