Category: Ruby on Rails ++

Activity Stream using Redis

One of the common UI patterns in modern web applications and services is a stream of recent events – commonly called the ‘activity stream’. An activity stream keeps the user updated with the latest happenings and hence keeps the user engaged. Activity streams can show updates about a variety of activities. Typically information regarding new comments, new friends, new posts etc. is shown.

Activity streams can be realtime push based or regular pull based. The push ones require some more infrastructure like, for example, Meteor to push latest updates to the client (the browser or a native app). We will discuss a backend implementation of a typical activity stream which could support both push or pull updates. Continue reading “Activity Stream using Redis”

Scaling your Ruby on Rails application with cloud computing : Heroku case study

As a business visionary, you know the problem you want to solve and you have a clear idea of how to solve it. But there’s one thing that nobody knows: Will people pay you to solve that problem? A well-built MVP (Minimum Viable Product), perhaps with a pivot or two, will lead you to the answer.

Ruby on Rails (“Rails” or “RoR” for short) enables software developers to build better software in less time with fewer errors. Rails is ideal for web-based MVPs. In fact, many ventures continue to use Rails well past the MVP stage. Groupon, Hulu, and Twitter are a few that come immediately to mind. Ruby on Rails helps developers write better webware in less time. Clients appreciate results, and Rails enables developers to deliver in a big way.
Once you have decided on how to develop your app, you have now to decide how to host and where to host it. There is a lot of buzz surrounding cloud web hosting these days and if you are researching various hosting options, you will have certainly run across this term.

So what exactly is cloud web-hosting?

Cloud web-hosting basically means hosting your web application to the cloud. The web application uses the resources of several clustered servers. This means that your website uses the virtual resources of several servers to accommodate all the aspects of hosting your site. The load is balanced, security is taken care of and hardware resources are available virtually so they can be used when needed. The cluster of servers is the cloud.

Cloud-Hosting1

Advantages of Cloud hosting

One of the primary advantages to cloud web hosting is its scalability. When you need additional resources you do not have time to wait for customer service to assist you by increasing your bandwidth allotment if needed. If you really have a spike in resources then you risk having your site suspended for causing degradation in services to other sites on your shared server. You may experience down-time or slowness on your site caused by the increased traffic. But with cloud hosting you can increase your available resources immediately, when you need it. This can save you a lot of stress and may even save some customers from drifting away because the process is seamless. Customers or users on your site will not see any change.

There are many ways to put your application on the cloud, some of the major ones being Amazon EC2, Linode, Rackspace and more recently Heroku.

Heroku: The way for cloud

Heroku is a cloud application platform. It means that Heroku only helps you host web applications. There is a catch though, you can use Heroku only if your web-application stack is supported by them. Do not worry, Ruby on Rails is supported by Heroku. In fact, they started their business supporting only RoR deployments. One of the biggest advantages of using Heroku is that you can scale very easily. Also you do not need to have a dedicated Devops team for maintaining your server. If your MVP turns out to be a success and you need to scale very quickly, then Heroku allows you to do that as well. Heroku has been architectured in a fashion such that you can easily add resources to your webapp as the load on your server increases and you can reduce the resources when the load has decreased. Heroku has the concept of workers, which they call dynos. You can increase or decrease the number of dynos your application needs based on the load that your server needs to handle. Your cost of hosting to Heroku is proportional to the number of dynos you need to support your application load. Hence, you only pay for what you use!

Is Ruby on Rails Not Enough? Incrementally Update Your Technology Stack

As a ruby on rails consulting company most of our technology stack for new projects starts with that platform. In most cases, our base stack, consisting of Ruby, Rails, Mysql and Jquery works well to fulfill most of our client requirements. To satisfy evolving requirements over time, we’ve consistently added different components built with other languages and frameworks to accomplish tasks where Ruby on Rails alone wasn’t enough.

We have built APIs using the evented NodeJS framework, switched to the high speed Redis data stores to perform complex in memory calculations and speed up critical tasks. We did this purely because Redis made it easier to perform complex data computations without having to frequently query the database. We built our APIs with NodeJS because it was easier to work with than the Ruby’s Eventmachine library for new programmers.

11-resized-600

Why we choose Ruby and Rails

In most scenarios the considerations for the starting stack is familiarity with the language, the frameworks and the ecosystem. The reason we choose Ruby and Rails for most tasks is because Ruby is a concise language that enabled us to do more and Rails helps us prototype and get features out of the door faster. The excellent Ruby community is another important factor and an important consideration in choosing the base stack for any project. Here is short discussion by Adam D’Angelo, founder of Quora on how they chose their starting stack.

Don’t Drink the Kool Aid

While we’d advocate the use of Ruby on Rails as the primary/starting stack for most projects, and strongly believe that it should be more than adequate to handle the requirements of these projects, we don’t particularly love the way its sold.

Being Agile and TDD friendly

We don’t believe that software engineering is an art, and we recommend you don’t buy into it either. It’s a practice – and almost a science. So saying that “Rails is Agile” and “Spring or Play does not aid in quick prototyping” make us cringe. Being able to be Agile or practice TDD depends largely on having a team of competent and well-rounded developers who understand the need to adhere to well-defined processes and ignore them when needed. The tools being used do affect this but only in a very small way. Test-driven development was in practice long before Ruby or Rails became mainstream. Your team is capable of NOT being Agile even while using Ruby on Rails and equally capable of not following TDD while using Rails.

So a capable and experienced Java team could turn out to be more productive than a team of average Ruby programmers.

Can you build a team?

Great products have great teams behind them. One of the biggest problems in building good resilient software has been the ability to find a team of good developers who can guide you to a successful launch. Though Ruby has made inroads into the enterprise world, it’s still largely a niche skill, and finding great developers hasn’t been easy. So establishing a team of good developers should be a greater concern than finding a team of programmers who can implement Ruby on Rails. If you have an excellent team of Java programmers, start with Java and Play.

If you are looking to partner up with an offshore team, here are some tips to help you choose the right partner.

Frameworks evolve

While Ruby on Rails will still be our first choice, we acknowledge that the JVM based language frameworks and Erlang frameworks have significantly evolved too. Play and Lift have grown increasingly popular along with their new JVM languages like Scala and Clojure. Companies like LivingSocial and Stripe actively choose Scala, Clojure and Java to do accomplish tasks they feel are better done on the JVM. Watch Xavier Shay talking about JRuby at Square and the use of JVM based languages. Erlang and its OTP frameworks have grown increasingly popular because they work well in building real time systems, which need high availability.

While its no secret that Ruby on Rails aids in quick prototyping and fast turnaround times, we’ve grown fond of some the new and traditional platforms like Javascript and NodeJS, JVM and C when the need to build evented, concurrent or faster systems arises. Though we hate to admit it but Ruby on Rails have their limitations, and a lot of companies have grown to accept this and embraced polyglot platforms, which enable them to use different languages and frameworks for their strengths in a single application.

Start Simple?

Knowing the benefits of each framework, we have grown accustomed to starting small and shipping quickly. It has helped us validate our business, technology and features quicker. It has worked well for us to iterate and improvise on popular features, and delete stuff that gets in the way. A small stack with a small code base works really well, so we prefer to partition our systems into well-defined logical components that speak to each other, rather than deal with one giant system.

Smaller logical components allow us to isolate problems and are easy to decouple. They give us the freedom to use different technologies that work well for the given problem. And our entire systems then comes together as components that talk to each other.

http://www.idyllic-software.com/services/ruby-on-rails-development

How do I know if Rails is not right for my project? How do I build a polyglot platform for my application?

That is where we can help! Give us a call or drop us an email, and we’ll help you evaluate your technology needs.

Why Entrepreneurs Love Ruby on Rails for Web Development

The statement conceived by Harvard Business School professor Howard Stevenson in 1975 most commonly defines entrepreneurship:

stevenson-lg

“Entrepreneurship is the pursuit of opportunity without regard to resources currently controlled.”

Stevenson’s definition of the entrepreneurial process opened up the term to all kinds of people, rich and poor, across continents. “They see an opportunity and don’t feel constrained from pursuing it because they lack resources,” said Stevenson. “They’re used to making do without resources.”

Eric Ries, founder of the Lean Startup Movement has a similar take on entrepreneurism:

“Entrepreneurship is a management system for dealing with uncertainty.” – Eric Ries.

Continually making fast decisions through that uncertainty is the essence of entrepreneurship. The gist of entrepreneurship is to try out many different things and build a business model that works, quickly. Entrepreneurs love anything that helps them make right decisions or even better, decide the right things for them.

Tech Entrepreneurs

For a tech entrepreneur, one of the most important decisions to be made is choosing the right technology stack, the layers of technologies or services used to create a software application. The traditional way of doing that is to choose a framework for every single need. For example, using this ORM, that tempting engine and that other cool new thing with a slick feature to develop your product. This is a very time consuming and resource-zapping approach, as every single option has to be evaluated at length to determine the best ones that will work together to make your system seamless. This is why many tech entrepreneurs chose Ruby on Rails development for their products. Ruby takes the uncertainty out of the equation.

Benefits of Developing With Ruby on Rails

  • Ruby technologies instinctually make targeted decisions based on best practices.
  • It is a full stack web framework that bases itself on conventions rather than configurations.
  • Ruby has been built for speed and quick time to market and focuses on developer happiness.
  • Ruby developers promote pragmatism over dogmatism.

Some of the biggest and most influential technology based companies today have built their successful platforms and companies using Ruby on Rails including, LivingSocial, Twitter and Groupon.

Find out how our Ruby on Rails can bring your product to life. Our Ruby on Rails development team can help you get it right the in the first time itself.

Choosing a right gem for your admin section

Admin sections are a part of most applications that one builds. Usually we lookup to active_admin for a quick solution. It is pretty straight forward when you have to do a few simple configurations and the dashboard. If your project is big and as the models start increasing plus if you need to do anything that is a little complex; it all starts to fall apart. The code becomes very hard to manage and maintain. So, it saved you the initial effort for the admin section but it brought its own set of problems.

There is another way you can be quick and the code will be clean and maintainable. The gem is inherited_resources. This gem actually helps you keep things clean, flxible and maintainable. I would strongly recommend taking a look at it before using active_admin gem.

Just a side note you could also use the inherited_resources gem in your regular controllers where you have your standard actions and want to add more to it. The readme has detailed information about its capabilities. You can find it here.

Setting up postgreSQL for RoR development

When working on Ruby on Rails application many developers use sqlite3 db for development purposes while the production database uses postgres/mysql depending the production environment. The exact reason why this practice is followed is not known but it can be attributed to developer laziness as setting up your application with sqlite3 db is very much easier as compared to setting up a postgres/mysql server in which you have to setup users for the database itself and then give them specific permissions as well. How difficult can this task of setting up separate database server on your development environment be? Well there is no straightforward answer for that, as the difficulty of installation of mysql/postgres depends on your development environment and how well supported it is.

So today we shall see how to setup a Postgres server on an Ubuntu machine.

First we begin by installing Postgres using apt-get

$ sudo apt-get install postgresql

Now it might happen that due to some permutation in the order you have installed your postgres server or pgadmin3, your postgres installation might not have been initialized and your database
might not have been created. Or you have been given a pre-installed Ubuntu machine and the first guy screwed up with the first installation of postgres; what do you do? You do this:-

$ sudo apt-get purge postgresql*
$ sudo apt-get purge pgadmin3
$ sudo apt-get install postgresql

On Ubuntu the debian installation script automatically installs a local user named postgres that is used to administer postgres instances and also sets up/ initializes a database to begin work with. You do not have to do that manually (going through pages and pages of postgres documentation).

Now you need to configure postgres for various databases and users

First we need to login to the postgres client. After the initial installation this is only possible through the postgres user before you have setup any other users. Hence we login as the postgres user

$ sudo su postgres
$ psql

This shall open the psql client that is used to communicate with the postgres server. Now we need to the hba_conf file that configures access control to you. Generally it is the /etc/postgres/9.1/main/pg_hba.conf. But to be sure please go to the psql prompt and

> SHOW hba_file;

This should give you the location of the hba file. This file stores the access control information for postgres users. Any users that you create on the postgres database using the create user option, are basically definition of roles of with respect to database administration (and hence are also called as roles in the Postgres world). The access to the database and authentication of a user is governed solely by the hba_file.

Now the access control list is declared in the following manner in the access control file:-

# TYPE      DATABASE        USER            ADDRESS                 METHOD
local            all                     vishnu                                                  trust

In here the TYPE column signifies the type of the connection being used to connect to the Postgresql database server. “local” signifies connections to the database server from the same machine via UNIX domain sockets, while “host” signifies connections from the TCP/IP stack.

The DATABASE column contains the name of the database that is being given access to a particular user. The USER column is for the name of the user. The ADDRESS column is from what IP addresses are connections to be allowed to the PostgreSQL server in case of remote access over the TCP/IP protocol.

The METHOD column is for the type of authentication that is going to be used to authenticate the user. The various types of authentication that are there are “peer”, “trust”, “md5”. “trust” and “md5” are the two authentication methods of interest to us. If you give your user the “trust” authentication then he/she will be able to access all those databases on the postgres server that you have given him/her access to, without requiring a password. If you have created a user for your database (while you were logged in as the postgres user) using SQL commands like

> CREATE USER <username> PASSWORD <password>

then while editing your hba_conf file you should add an entry for that particular username and METHOD “md5”

Now in case of Ruby on Rails application you can create users as you specified in your config/database.yml through the SQL method while logged in as postgres. After that you can edit your hba_file to add that user with md5 authentication and you are done. You can now develop your Rails app with a postgres server can be as close to your production environment as possible.

Branching, Merging and Restoring branches with SVN

The modern day teams use modern version control system like Git and Mercurial and no question they are better in usability than the version control systems that were popular like 5 years ago something like an SVN. But if you are still using or if you have to use SVN and need to use features like branching this blog might prove to be of some help. Don’t panic it is not as bad as Git or other modern VCS’s hype it to be IMO. Below I am listing just a couple ways that you could use branching. In this article, I will be covering:

(a) Creating a new branch
(b) Merging from trunk to your branch
(c) Merging your branch to the trunk
(d) Deleting a branch
(e) Restoring a deleted branch

Creating a new SVN Branch

If you or your team are working on a new module and you would like to keep your trunk production you will go about create a new branch to work on. The process of creating a new branch and this assuming you would diverge from the trunk:

  • Checkout the complete svn project if you haven’t already.
svn copy svn+ssh://host.example.com/sources/project

If you have an existing complete project then cd into your trunk and “svn update” it.

  • Copy the latest trunk into the branch
    svn copy svn+ssh://host.example.com/sources/project/trunk 
    svn+ssh://host.example.com/sources/project/branches
    /YOUR_NEW_CREATED_BRANCH 
    -m "Creating a branch for "

    The output of the above command would be similar to your The above command and done your new branch is created.

  • If your team mate has checked out trunk lets say and would like to switch their branch:
    svn switch svn+ssh://host.example.com/sources/project
    /branches/YOUR_NEW_CREATED_BRANCH

    to make sure a branch is checked out use:

    svn info

 

Merging from trunk to your branch

svn merge svn+ssh://host.example.com/sources/project/trunk .

use the ‘–dry-run’ option to check the incoming changes without actually making the merge; use ‘-r:’ to merge revisions.

svn commit -m "Your merge commit message"

Merging your branch to the trunk

svn merge svn+ssh://host.example.com/sources/project/trunk  
svn+ssh://host.example.com/sources/project/branches
/YOUR_NEW_CREATED_BRANCH

Again you could use the the flags mentioned above.

svn commit -m "Your merge commit message from branch to trunk"

Deleting a branch

Once you are done merging your branch -> trunk and cd into the project root dir

svn delete 
svn+ssh://host.example.com/sources/project/branches
/YOUR_NEW_CREATED_BRANCH   
-m "commit message"

Restoring a deleted branch

In case a branch needs to be restored and you need to lookup something.

svn copy 
svn+ssh://host.example.com/sources/project/branches
/YOUR_NEW_CREATED_BRANCH@rev_num
svn+ssh://host.example.com/sources/project/branches
/YOUR_NEW_CREATED_BRANCH_restored
-m "commit message for restoration"

Small Tips

  1. Lets say you have been merging and diverging away from trunk frequently and when you are trying to merge trunk in your branch and you see a tree conflicts. What I would do is backup the file text conflicts:
    svn resolve --accept working

    Then you might want to update the files appropriately and commit the code.

  2. When you work on merging, merge as frequently as you can. I would check for updates to the trunk every 2-3 days and bring the incoming from trunk to your branch.
  3. If you are working in a team. I would merge when all the team members are present.

I hope this has saved time for people reading this blog. I have some SVN knowledge under my belt and would be happy to answer the questions to the best of my knowledge.

Sinatra for Speed

Sinatra is often seen as a framework to suit small projects. However, at Idyllic Software we have seen it as a big add value to large scale applications.

Most high traffic, large scale applications have a functionality that are used more than others. Some of these functionalities may also have time consuming tasks associated with them which makes them take longer to execute. This substantially reduces the load that the application can handle at that point in time when these tasks are being performed.

You might be able to performance tune the application to a certain extent, after which the recommended solution is to add a few more servers to the mix and load balance. To add to the miseries, every time these high performing tasks are modified, deployment is required for the whole application which reduces the up time of the application and requires deployments too often.

If you are able to take these tasks and manage them separately, then the application can not only scale better, but it requires much fewer deployments. This is where Sinatra can come to the rescue. The key is identifying the singular tasks that can be managed in such way.

A good first step is considering anything that can be handled asynchronously. The parent application can then speak to the Sinatara application using REST API that is exposed and continue its operations.

It is important to note that Sinatra has a very small foot print. It is 1500 lines of code as compared to a full blows rails stack which is more than 10,000 lines of code. By visiting Sinatra’s site, you can find a list of applications and websites that use the Sinatra framework (including the business-networking site LinkedIn)!

7 Great Websites Built Using Ruby on Rails

When it comes to web development, Ruby on Rails is our bread-and-butter. Our team is skilled using RoR, and we’re proud of the amazing things we can do with it. Of course, RoR is also an open source project, so a lot of people have been able to create some pretty great websites using it. Below, we’ve listed seven of our favorites that you might recognize. Many of these immensely popular sites are so large and complex, it’s no wonder they relied on Ruby on Rails developers.

1. Hulu


Hulu has relatively recently become the go-to place to catch up on TV shows online. They also host movies and exclusive Internet videos. If you have access to Internet, you no longer have to worry about missing the latest episode of your favorite show. RoR helps make Hulu’s large library attractive and easy to navigate on a variety of platforms.

2. Funny or Die


Funny or Die is comedian Will Ferrell’s brainchild. It hosts a deep database of videos featuring Ferrell and his funny friends, as well as other hilarious videos and pictures from around the web. Since the site is built on RoR, it boasts a number of slick features, like a community-based voting system for determining if a video is “funny,” or if it should “die.”

3. Yellow Pages


Remember “phonebooks?” Yeah, we don’t either. This website is the online incarnation of the giant yellow phonebook that used to (and occasionally still does) show up on doorsteps around town. This version doesn’t ever need recycling, and good RoR development has made it a joy to use.

4. Bleacher Report


Bleacher Report is a sports-focused website that relies heavily on user-created content. Because of the vast network of contributors (there are roughly 1000 original content postings a day), Bleacher Report needed to be a user-friendly system. It also integrates social media directly into the site.

5. Basecamp


Basecamp started it all. The Ruby on Rails framework was extracted from Basecamp, a web-based project management tool. Between providing the world with RoR and helping workers track progress on projects easily, Basecamp has created many unique experiences for a wide array of users.

6. Groupon


When Groupon first hit the scene back in 2008, it made huge waves in its test market of Chicago. Four years later, the company has expanded into cities around the world and now offers consumers a way to get great deals right in their own neighborhood. With RoR, their site has been designed to be simple and user-friendly, ensuring that each visitor gets exactly what they want.

7. Manage My Life


Manage My Life is a destination for life management that helps do-it-yourselfers cross items off their to-do lists, manage projects, find expert answers to their questions, and even download product manuals for tools around the house. Managed by Sears, the site was built on RoR to give Sears customers an easy way to put their purchases to work.

These sites are just a handful of examples of great things that have been done with Ruby on Rails development. What have we missed? Share some of your favorite RoR sites in the comments below!

Subscribe To Our Blog

Get access to proven marketing ideas, latest trends and best practices.

Next up home

Contact

Lets build cool stuff

Share your contact information & we will get in touch!

I want (Tell us more about your dream project)