SSH Tunneling for Ruby on Rails app

It is quite annoying to develop and test an app which is likely to receive data/notification from a third party site if your development computer isn’t globally reachable. You have to deploy to a server and test it and do this each time until it completely works. Examples of such cases include:

  • Facebook app development
  • PayPal or any other payment gateway integration

While there are probably several options, SSH Tunneling is the simplest, at least to me. It needs less than 2 minutes to configure. Let’s do it.

I’m assuming:

  • You’ve a dedicated server/VPS with root access or somehow access to sshd_config file (we’re going to call this remote server)
  • Your domain is dev.awesomeapp.com and which points to the above server with IP 198.198.115.47
  • You wanted the remote server to listen to 80 port
  • You’re running your rails server at port 3000 in your development computer (we gonna call this local server)

(You may have to change the values marked in italic font as your own settings)
Continue reading →

Sunspot – power up your app with solr before knowing it

The title is a bit skeptical. Isn’t it? But trust me, it’s true. You can implement solr power searching in your Ruby on Rails application without knowing Solr. Yes, you off course know about Solr. What you don’t know is how to make it work for you. Let’s check how can you power your application with Solr using Sunspot gem.

What is Sunspot?

Sunspot is a Ruby library for expressive, powerful interaction with the Solr search engine. Sunspot is built on top of the RSolr library, which provides a low-level interface for Solr interaction; Sunspot provides a simple, intuitive, expressive DSL backed by powerful features for indexing objects and searching for them.

Using the sunspots DSL, you can easily implement solr powered searching. Its drop-in support with Rails models let you power your site with a few lines of codes.

Installation

Add the following line in your Bundle file.

gem 'sunspot_rails'
gem 'sunspot_solr'

Then run ‘bundle install’.  Continue reading →

Rails 4 “Routing Concerns”

Today, while digging routing guides of Ruby on Rails, I spot this new feature which is available in Ruby on Rails 4. Routing Concern is a wonderful concept of re-using routing definitions. I just love how Rails try to reckon on DRY principle. I’ve worked in a project where routes.rb has about 50 lines of definition while the project was progress not more than 20%. There were many similar routing definitions in different scopes (namespaces). Routing Concerns will now enable us write less codes to define application routes.

I’m not going to show how to use it as Rails guide already did the job. I’m simply copying the codes over here.

Update:

I’ve also found this blog shared on facebook by one of my friend

2013 RubyConf Bangladesh

I was presenting in 2013 RubyConf  Bangladesh event

I was presenting in 2013 RubyConf Bangladesh event

Well, finally the moment came. RubyConf Bangladesh finally happened at the BASIS Auditorium. The whole day was fun.

The event was scheduled at 11am. However, audience started arriving from 9am. We’ve been thrilled to see the enthusiasm among the audience. The event started 5 mins later than scheduled.

Initially Fayaz Taher, from BDTech Social, welcomed everyone to the conference and invited Fazle Taher, from Infra Blue Technologies, to present his Keynote. After the keynote, there was a interesting Ice Breaking session. In that session, audience are encouraged to meet and network with new people, exchange business cards/contact details. At the end of that session, a pop question asked to audience to name of 5 new people they just met. S M Rasel (from NewsCred Inc) won that prize. He is my co-worker and he proved what he always used to say (he used to see he “can remember names using some techniques”).

Continue reading →

Amistad – Facebook like friendship management in Ruby on Rails

Today I’ve decided to write something about the Ruby Gems that I used. So I’ve started this series (Ruby Gems). This is the first post of the series. I will try to write regularly.

When I was working on my pet project MovieMates, I needed to implement a friend relationship. Initially, I was going to do it myself. However, later I thought I should, at least, google a bit to check if there is already some similar solutions. Then I found Amistad.

The current version of Amistad supports ActiveRecord 3.0.x, Mongoid 3.0.x and MongoMapper 0.12.0.

Installations

Add following line to your Gemfile

gem 'amistad'

Continue reading →

Ruby and MongoDB Web Development Beginner’s Guide Review

I remember the days when I’ve used MongoDB  in simple Ruby on Rails (RoR) project using Mongoid. It’s so simple to use MongoDB with RoR without knowing much about it. While using MongoDB, as a project requirement, I became more interested about it and decided to dig more. The moment I wanted to learn more about it, I found the book Ruby and MongoDB Web Development written by Gautam Rege. Thank goes to my colleague Rubayeet Islam, who suggested me this book. When I started reading it, I started feeling at home as I’ve already familiar with several Ruby/Rails/MongoDB concepts that I’ve learned during my works. However, here is my overall feelings about the book.

The first four chapters of the books talks solely about MongoDB. You will learn how to install it, run it, query it, use complex queries etc. and all of these using the default mongodb client.

Continue reading →

Beginning Ruby From Novice to Professional

Beginning Ruby
I used to review books a bit detail. I include as much information as much possible and make senses. However, I’m going to make an exception this time. I will write a quick review on the book titled Beginning Ruby, From Novice to Professional authored by Peter Cooper published by Apress. The exception that I’ve just mentioned is that this review will be my shortest book review ever.

I’ve started by Ruby journey in a reverse way. First I’ve started working with Ruby on Rails directly (But I’ve read these tutorial to get basic idea). When I’ve found it’s fun, I started learning Ruby following this book.

The only thing I can tell about this book is “This is the one of the best book, of its kind, I’ve ever read”. So, If you want learn Ruby, you can consider this book without any second thoughts. That’s all about my review :).