Posts

sunspot_rails the Sunspot library for Solr search.

Now its very easy to integrate solar search using sunspot_rails gem in rails 3 for fast searching.  Please follow the below steps to use solar search. 1) first install the gem    gem 'sunspot_rails'    gem 'sunspot_solr'   # optional pre-packaged Solr distribution for use in development 2) Run the bundle command to install the gems. 3) Run      rails generate sunspot_rails:install      to create the configuration file for the solar search. 4) Now you need to start the solar server     bundle exec rake sunspot:solr:start 5) If you have some exiting data in the data base please execute the command     rake sunspot:reindex 6) Now we are done with our setup.we need to configure our model so that search will work.    let say we have one event model in our application like    class Event < ActiveRecord::Base       attr_accessible  :content, :title     end Now if we want a full text search on the Event model. We just need to add one block in t

mongo.js:L112 Error: couldn't connect to server 127.0.0.1:27017 atsrc/mongo/shell/mongo.js:L112

mongo.js:L112 Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:L112 Stop mongodb service sudo service mongodb stop Remove mongodb lock file sudo rm /var/lib/mongodb/mongod.lock Change ownership from root to mongodb path sudo chown -R mongodb:mongodb /var/lib/mongodb/ Start mongodb service sudo service mongodb start Test mongo app mongo Then you will be able to execute successfully (i hope).

Configure Twilio In rails 3

Now you can make voice call and can send text message using Twilio api in rails 3. Follow the below steps for setting up Twilio in your Rails application. 1) First create a new rails application using rails new twilio_app . 2) Add the gem "twilio-ruby" in your gem file and run the bundle command. 3) Go to http://www.twilio.com/ and create a free new account. After creating the account just go to the https://www.twilio.com/user/account   and get the ACCOUNT SID and AUTH TOKEN from there . 4 )Now for sending sms put the code inside your controller.    account_sid =  ACCOUNT SID    auth_token =  AUTH TOKEN    @client = Twilio:: REST ::Client. new account_sid, auth_token    message = @client .account.sms.messages.create( :body => "Hey Jhon !" ,              :to => "+14159352345" ,              :from => "+14158141829" )    puts message.sid for trial account to  number must be registered inside tw

Delete and reset database in rails 3

Suppose I have a Ruby on Rails database . I want to delete everything and rebuild the database. Please follow the following steps: rake db:drop rake db:create rake db:migrate  To reset and reload your current schema with all. Just follow rake db:reset rake db:migrate

Rmagic installation problem in rails 3

How to install ImageMagick  In Rails 3 Before installing r magic please installed the required library in your system. please follow the Steps. sudo apt-get install imagemagic sudo apt-get install libmagickcore-dev sudo apt-get install l ibmagickwand-dev After successful installation of the above 3 libraries now run gem install 'rmagick' Now rmagic will install successfully. :)

How to write stored procedure in rails 3

Writing Stored procedure in rails 3 Now using Mysql2 gem writing stored procedure is pretty much easy. Just we need to follow the below steps to write  stored procedure in ORM. 1) Connect the database. client = Mysql2::Client.new(:host => "localhost", :username => "root", :database => "XXX", :password => "XYZ", :flags => Mysql2::Client::MULTI_STATEMENTS ) This extra flag option is most important and multiple result sets is normally used when calling stored procedures that return more than one result set. 2) Fetch the data. result  = client.query( 'CALL sp_test'); It will return the Result set. Now result contains first result set and to fetch the Next result set we need to follow the next step While (client.next_result)    result = client.store_result  #To get the next result set end

Rails 3 ActionDispatch::Cookies::CookieOverflow

ActionDispatch :: Cookies :: CookieOverflow ( ActionDispatch :: Cookies :: CookieOverflow ): Problem in rails 3 devise. The problem is with session["devise.facebook_data"] = env["omniauth.auth"] . Twitter's response contains an extra section that is very large and does not fit in the session. One option is to store env["omniauth.auth"].except("extra") in the session instead. This is issue arises where we are storing more than 4K of session data.