Multiple model search in rails with solr

lrSearching is much easier if you use solr or elastic search, no need to write complex database queries.

If you want to integrate solr with your rails application means there is a gem available

Add to Gemfile:

gem 'sunspot_rails'
gem 'sunspot_solr' # optional pre-packaged Solr distribution for use in development

Bundle it!

bundle install

Generate a default configuration file:

rails generate sunspot_rails:install

If sunspot_solr was installed, start the packaged Solr distribution with:

 bundle exec rake sunspot:solr:start

Then add the following code in model file which you going to search

searchable do
  text :<field_name>

In your controller queries

@search = Project.solr_search do
fulltext params[:search]
@projects = @search.results

Thats all, if you pass search params from your view file, then solr will give you the relevant projects.

Now I will show you how to search multi models in same querie,

simply add the same

searchable do
 text :<field_name>

In model files which you need to search, Then in your controller

@search =,Comment, File) do |s|

@result = @search.result

will give you the result from project, file and comment models


Easy Ruby on Rails install

Whenever I setup new Linux for developing rails application. I feel bit tired of installing all necessary things for rails development.

For that I have written one shell script, that install most of the things requires for rails development. If you want this lazy thing. You can check here

And use it , fork the code and update if you feel some thing to be added.


Audio Streaming in Ubuntu using Shoutcast and Internet DJ Control

     If you ever want to stream your rails application audio file using shoutcast I will show you how to do this

firt install and configure shoutcast
cd /tmp

If you get error while trying to execute this command then you don’t have wget command installed to your system. For Debian and Ubunutu use the following command to install it:

apt-get install wget

Again If you get the error then go to the shoutcast site then download the package

 Next we need to create the folder for our shoutcast server and extract the archive

mkdir /home/shoutcast
tar -zxf sc_serv_1.9.8_Linux.tar.gz -C ./home/shoutcast

Navigate to the shoutcast folder and clear the config file because it has comments and configuration codes it may confuse you if you see them first time any way its better to clear the file

cd /home/shoutcast
echo > sc_serv.conf

5. Open the file sc_serv.conf

nano sc_serv.conf

Paste the following text


You should modify these settings:

A. Change the MaxUsers , It can be many users but set minimum as possible
B. Set the Password to a value that you know because you need it to connect to the server in order to stream music to it.
C. Optionally you can change the port by changing the PortBase to some different port.
D. AdminPassword is the web interface password. Web interface is used for banning and kicking users from the server.

6. Start the server


Thats all next is to go for broadcaster software in windows and mac SAM broadcaster is a excellent software we have but If you  want to use ubuntu then InternetDJcontrol shortely called as IDJC


first we need to install idjc


sudo apt-get install jackd qjackctl


Open Limits.conf

sudo gedit /etc/security/limits.conf

Add the following lines into the file :

@audio - rtprio 99
@audio - memlock unlimited
@audio - nice -19

then run idjc you can find it by searching IDJC in ubuntu search bar This is GUI of IDJC


Go to view-> output you will see the window like this there go to configuration -> connection -> new and fill the details as shown then click OK


then in configuration -> format fill the details as follows

configuration image

configuration setting

If all set to correct then above localhost:8000 (8000 may change depends on port you set)  will appear as shown if not check the settings againlocalhost then click the localhost:8000 button if everything goes well the button has need to be stayed as pressed like this  then the green light will glow

connectedand that’s all you may listen your radio on by searching your radio name which you given at the first time you starts the IDJC , if the green indicator doesnot glow check the shoutcast server running and see the serv.conf file port setting

If you want to use it in your rails application the jplayer fetch the stream and play it well check it on their website jplayer stream player


Thank you for reading me…………………


Gemmified version of jquery plug-in stick

Sticky is a jQuery plugin that gives you the ability to make any element on your page always stay visible .This is gemmified version of sticky

jQuery sticky 1.0.0 –


Add this line to your application’s Gemfile:

gem 'sticky-rails'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install sticky-rails


Sticky is a jQuery plugin that gives you the ability to make any element on your page always stay visible. , so please check if you are using the jquery on your rails app

//= require jquery

Your app/assets/javascripts/application.js must appear like:

//= require jquery
//= require jquery_ujs
//= require jquery.sticky.js
//= require_tree .

Basic Structure example from



If you are going to use coffee script:

$(document).ready ->

Or just javascript:


For more documentation please checkout the sticky-rails 4 repository here:

Gem Author