Archive for the ‘Technical Articles’ Category

March 3rd, 2011

How to Set up Redmine-project tracking system

Installation Steps

1) Make sure ruby 1.8.7 and Rubygem are installed

2) Install Rails and few required gems

gem install rails -v=2.3.5
gem install rack -v=1.0.1
gem install -v=0.4.2 i18n

3) Checkout the Redmine source code

svn co http://redmine.rubyforge.org/svn/branches/1.0-stable redmine-1.0

4) Go to redmine-1.0/config and rename few files

mv database.yml.example database.yml
mv email.yml.example email.yml

and do the database and email configuration

5) Run rake db:create to create database. then run database migrations using rake db:migrate

It will create tables and an administrator account.
If you get this error:

Rake aborted!
no such file to load — net/https

you need to install libopenssl-ruby1.8, in ubuntu, just like this: apt-get install libopenssl-ruby1.8

6) Generate a session store secret.

rake generate_session_store

7) Insert default configuration data in database, by running the following command:

rake redmine:load_default_data

This step is optional but highly recommended, as you can define your own configuration from scratch. It will load default roles, trackers, statuses, workflows and enumerations.

8 ) Setup is complete. Start the server

ruby script/server

9) Use default administrator account to log in:

login: admin
password: admin

For more information visit http://www.redmine.org/wiki/1/RedmineInstall

February 10th, 2011

Group chat room in Rails

Contributor : Nagendra

Introduction:
Chat Engine is a lightweight rails engine that heavily uses jQuery and memcached to implement a very simple group chat room.

Features:

* You must enter a nickname to be part of the chat room.
* All logged in users are shown in the user list
* Lines in the chat that mention a users nickname are highlighted.
* Inactivity timer will logout users from the client side.
* rake task to logout users whose browsers do not allow ajax requests in the unload event.
* The ability to mute specific users (from script/console). Muted users will see their own messages, but no one else will.


Implementation:

install chat-engine

./script/plugin install git://github.com/amiel/chat-engine.git

copy assets

rake chat:sync

include assets, don’t forget jquery

<%= stylesheet_link_tag 'chat' %>
<%= javascript_include_tag 'jquery-x.x.x.js', 'auto_scroll', 'chat' %>

use the chat_overlay partial

<%= render :partial => 'chats/chat_overlay' %>

Note: make sure you have Jrails installed and the prototypes are properly included.

February 9th, 2011

File Uploading with Paper clip

Contributor : Nagendra


This is one of the most useful plug in that can be used in your application when you require to upload a file as attachment to your application, its quite easy to use and with the help of paperclip scaffolding you can achieve file upload feature very easily, below i have explained the steps to create a simple application using scaffolding that enables the file upload feature with the help of paperclip plugin.


Steps:
Install the required gems to run the paperclip plugin from the below mentioned command,

$ gem sources -a http://gemcutter.org
http://gemcutter.org added to sources
$ sudo gem install view_mapper
Successfully installed view_mapper-0.2.0
1 gem installed Installing ri documentation for view_mapper-0.2.0...
Installing RDoc documentation for view_mapper-0.2.0...

1. First you need to create a rails app and change the database.yml setting and set things to install the plug in $rails student -d mysql

2 Then you have to just install the paperclip plugin into your application from the below mentioned command,

$ ./script/plugin install git://github.com/thoughtbot/paperclip.git

3. Once the plugin is installed, let me show you to create a simple scaffold with paperclip file attachment feature in it.
Just create a simple scaffold and check it out,

$ ./script/generate scaffold_for_view Student name:string branch:string comment:string --view paperclip:photo

Then you need to enter $ rake db:create and $ rake db:migrate
This will create the paperclip file attachment feature, just run $ script/server and check it out. The display looks just like the image i have mentioned at the beginning.

February 8th, 2011

Install Image-magick and rmagick for rails

Contributor : Nagendra


Start by removing any old versions previously installed via apt-get:

sudo apt-get remove imagemagick

Then update apt-get and install some supporting packages:

sudo apt-get update


*(sudo apt-get install
libperl-dev gcc libjpeg62-dev libbz2-dev
libtiff4-dev libwmf-dev libz-dev libpng12-dev
libx11-dev libxt-dev libxext-dev libxml2-dev
libfreetype6-dev liblcms1-dev libexif-dev perl
libjasper-dev libltdl3-dev graphviz gs-gpl pkg-config)*


*its a single line command.

get the Imagemagick package from this link:

http://www.imagemagick.org/script/install-source.php#unix

Once the source is downloaded, uncompress it:

tar -xzf ImageMagick.tar.gz


Now configure and make:

cd ImageMagick-6.5.0-0
./configure
sudo make
sudo make install


Add the following line to ~/.bashrc:

export LD_LIBRARY_PATH=/usr/local/lib

Update: If you still get an error like the one above, try running ldconfig:

sudo ldconfig

You can confirm the install and available formats with:

identify -list format

Once Image magick is installed install rmagick gem by typing the command:

$sudo gem install rmagick

February 4th, 2011

Configure Sphinx in Rails application

Contributor : Nagendra



Install Sphinx

Just run the following three commands on your server or dev machine to install Sphinx:

./configure make sudo make install

That will setup Sphinx with default for use with MySQL. If you want to use it with PostgreSQL, then run configure with the following flag:

./configure --with-pgsql

Note: you can download the sphinx from http://sphinxsearch.com/downloads/beta/

Install Thinking Sphinx

Even though there are a couple of Sphinx plugins for Rails, I chose to go with Thinking Sphinx, as it seems to be the most popular and feature complete.
So you can install it as a Rails plugin using
script/plugin install command:

script/plugin install git://github.com/freelancing-god/thinking-sphinx.git

Writing code to use sphinx search:

We now need to index our models. This consists of adding a few small lines of code into each model that you want to be able to search. So lets say we have a Blog app (doesn’t everyone!), which has a Post model. And that Post model contains the usual title and description fields. We therefore add the following bit of code beneath our association declarations in

app/models/post.rb:
define_index do indexes title, description end

Those very short three lines will tell Thinking Sphinx to index the title and description fields of the Post model, and allow us to search through all our posts. Now we just need to index and start Sphinx. And Thinking Sphinx makes this very easy with it’s handy Rake tasks.

Just run this:

rake ts:rebuild

That will stop (if it is started), index and start Sphinx for you. Now we need to create a quick search form. This will eventually be a global site search, and not just a Post search. So we will create a new controller:

script/generate controller search

Then create a view at app/views/search/index.html.erb and place the form within it:

Now in your new Search controller, create a new create action:

def create @posts = Post.search params[:search] end

Create your create view at app/views/search/create.html.erb with a bit of code to display your @posts in the usual way.

Note:

We can even paginate our results using the WillPaginate plugin:

def create

@posts = Post.search params[:search], :page => params[:page], :per_page => 10 end



Get Adobe Flash playerPlugin by wpburn.com wordpress themes