<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Akshay Mishra on Medium]]></title>
        <description><![CDATA[Stories by Akshay Mishra on Medium]]></description>
        <link>https://medium.com/@mishra.akshay91?source=rss-c0baab2b7b12------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*CJiL-4jH77RIJOaa.</url>
            <title>Stories by Akshay Mishra on Medium</title>
            <link>https://medium.com/@mishra.akshay91?source=rss-c0baab2b7b12------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 05:44:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mishra.akshay91/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to set up an existing Rails project in your workspace?]]></title>
            <link>https://medium.com/@mishra.akshay91/how-to-set-up-an-existing-rails-project-in-your-workspace-b3f1323ea65f?source=rss-c0baab2b7b12------2</link>
            <guid isPermaLink="false">https://medium.com/p/b3f1323ea65f</guid>
            <category><![CDATA[beginners-guide]]></category>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[Akshay Mishra]]></dc:creator>
            <pubDate>Wed, 07 Feb 2018 23:43:29 GMT</pubDate>
            <atom:updated>2018-02-07T23:43:29.046Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi fellow Rails programmers,</p><p>Today I am going to write a blog to help our fellow rails beginners and hopefully this will inspire them to work on existing amazing open source rails projects. Contributing to open source projects is a pretty good way to learn new technologies. But it is happens quite frequently that a beginner gives up too soon due to intimidating set up procedures! I have gone through this, so decided to write a this blog post.</p><p>Few days ago I came across this link — every serious rails developer should bookmark <a href="https://github.com/ekremkaraca/awesome-rails">Awesome rails</a> projects on Github. It’s a really awesome place to start exploring Rails. So, I chose a project ‘Askaway’ to begin with. I picked this idea because I think I myself would like to work on something like this. Process to set up initially may differ a little in every project, so I’d suggest you to stick with this project while following this post, you may work on other idea later, but do post setup steps on your blog, and maybe post link to that blog post in the comments section below.</p><p>To start, I imported ‘askaway’ from the list and set it up on my local machine (Fedora 25). You can find the live running project <a href="https://nzelection.askaway.org.nz/">here</a> (might be dead if they stopped working on it) and its Github repo <a href="https://github.com/askaway/askaway">here</a>. I will use Cloud9. It is basically your isolated workspace in the cloud! You can afford to mess the workspace, try whatever you want, clone it, destroy it and create another workspace! Also I will not be installing PostgreSQL GUI client as this is only for the demo purpose and GUI client is not needed here.</p><p>One more thing before I start, I’d encourage any constructive feedback from the readers. Because one caveat here is, since the main purpose of this blog is just to walk you through process of importing an existing rails project and getting it up and running, I may not follow production standards. e.g. I am setting up prod db in same environment as test and development db, which is not a good idea, but you are free to follow industry standard standard. I may skip over some explanations as to why I did that step, as it was needed to be done from pretty evident error messages when I installed first time. Every rails project is different and needs different set of libs, etc. So only look at the breakdown of the steps instead of going deep in each step.</p><p>So now, our task can be divided roughly among below small steps:</p><ol><li>Create an account on <a href="https://c9.io/">Cloud9</a></li><li>Installing Ruby. Apple ships ruby along with Mac. <a href="https://www.ruby-lang.org/en/documentation/installation/">Here</a> is the guide if you need it.</li><li>Installing Git and importing code. <a href="https://git-scm.com/book/en/v2/Getting-Started-Installing-Git">Here</a> is the guide to install git client if you need it.</li><li>Installing gems (We are using bundle here, rails v2.3+)</li><li>Updating apt-get (or yum, whatever) package info</li><li>Setting up database server (Postgres in our case here)</li><li>Modifying database.yml to suit our db setup</li><li>Creating users/roles, setting up privileges</li><li>Rail’s db migration using rake utility</li><li>Booting up default rails web server and that’s about it!</li></ol><p>I have given transcripts of all commands at the end of the tutorial in case it is not visible in the screenshots.</p><p>Now first things first, create an account on Cloud9! Go to <a href="https://c9.io/">https://c9.io/</a>!</p><p>Now you can create a workspace, either by choosing one of the templates provided or without one.</p><p>You have to copy the URL to clone a Git project from its github repository. For those who do not know this, please copy from page as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6NEfruX1ZBxBdh17." /></figure><p>It’s time to create a workspace now, so login to your cloud9 acc and spin up a workspace by clicking on ‘Create a new workspace’, but don’t choose any template for now.</p><p>Also enter Git repo URL for cloning the workspace in the text box as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WJM0D68oo_7lX6nS." /></figure><p>Once you click on the green button at the bottom, it should start a container inside which your workspace will reside. Refer to below screenshot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*B3fgBRQFvd_I78dP." /></figure><p>Once this is done, it should open what looks like an IDE or code editor like sublime and also console windows at the bottom. This is the screen where we will perform all actions now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eADChofNVrrOFAXq." /></figure><p>One good thing about Cloud9 is that you automatically have sudo and root access in this workspace to the default ‘ubuntu’ user, and you can pretty much install anything. But those who are working on local machine (instead of cloud9) will need to have sudo access and will need to prepend ‘sudo’ before many commands.</p><p>First thing you have to do after seeing above screen is, browse to config directory on the left pane, and change the name of file database.yml.example to database.yml. If it was database.yml, don’t touch it. This name is the standard convention in rails. The author has given the conf file just as an example for a particular RDBMS vendor, and you can override with any database vendor as you wish.</p><p>Note that you have to make a few more changes to this file in future. I’ll explain it when the time comes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4H-sJHhDTHDvYqQT." /></figure><p>Now check if ruby (&gt;=2.2.0) is installed. One thing to note is, Cloud9 is giving us Ubuntu 14.04, and it has ruby pre installed. It doesn’t have rails installed yet. But you have something called Gemfile. And bundler is used to install all dependencies mentioned in this file using a simple command ‘bundle install’. One thing to note here is, even though all steps listed above are generic and applicable to all rails project, they may differ a little for every project because sometimes different ruby gems need different C, C++ libraries, etc for building native extensions, and if you do not have it installed, ‘bundle install’ will fail giving errors like <a href="https://www.google.com/search?sourceid=chrome-psyapi2&amp;ion=1&amp;espv=2&amp;ie=UTF-8&amp;q=rails%20failed%20to%20build%20gem%20native%20extension&amp;oq=rails%20failed%20to%20bu&amp;aqs=chrome.0.0j69i57j0.7567j0j7">this</a>, and in that case, you have to read the error message carefully, see which library is needed by the gem, search on google what is the package that needs to be installed for this, and then install it using apt-get (or yum if you are working on CentOS, etc) and run ‘bundle install’ again. Repeat this until command finishes successfully.</p><p>For this project, bundle exec runs pretty smooth on given Ubuntu 14.04 setup. I faced a little more issues while working with Fedora 25 on my local machine, but using error messages, I was able to resolve. So, if you are in that situation, don’t give up and keep trying, post in the comments section if you are still unable to get all gems installed, I’ll try to help if I can.</p><p>Now, back to installation — make sure you are in project directory and run ‘bundle install’ from the project directory in the console, but it will fail as bundler gem is not installed by default. So first run below commands as shown:</p><p>‘gem install bundler’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nd8MQF0VpH89YGeJ." /></figure><p>Once bundler is installed, you are free to run bundle install but, in this project, I have noticed a gem called ‘eventmachine’ fails to build while installing. There is a workaround I have found which needs an update in ‘Gemfile.lock’ file. We usually do not touch it but in our case since app is breaking, open that file, find eventmachine in the list and change its version from 1.0.3 to 1.0.4</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Od4WmgMItKOL5Xdh." /></figure><p>Now run ‘bundle install’ and wait until all gems are fetched from rubygems.org, native gems are built and installed. You should see something like below on the screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*t_7k7FTMOZ8mfYR9." /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_tSbpsRkjdfG2biD." /></figure><p>Nokogiri gem will throw a warning regarding a particular library, check it it of concern to you. I’ll leave it as it is.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HswiWTq0x7Np-_NM." /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gyaRR9W_xeoigWk-." /></figure><p>In the end, it’ll say bundle install is complete. Once it is done, next step is to set up DB now!!!</p><p>Askaway is using an open source DB named Postgre, and I’m going with the same option. You can use another just in case you already have one set up already. You may want to change the database.yml file in that case. Search google in case you have any doubts. There is huge info available on this topic.</p><p>Rails uses an interesting technique called ‘migration’ to hide app from underlying database. If you have used direct SQL queries (or rather script) either to setup db for the app with another RDBMS vendor, you will to change the syntax for all of that script to make it work for that RDBMS. But rails migration takes that headache off our load, and generates SQL script to run on any vendor that you set up correctly in database.yml. Rails, you beauty!</p><p>Now back to installing postgres, so go ahead and below 2 commands on your terminal of cloud9. First step is optional but recommended.</p><p>sudo apt-get update</p><p>sudo apt-get install postgresql postgresql-contrib</p><p>First is updating your repo, and second one is installing actual postgres server.</p><p>You should see output something to similar below.</p><p>For 1st commands,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hR_W_-f-2PHplCUk." /></figure><p>And once first is finished, go ahead and run second. It should end with some similar end below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QVBVO_2l_OR4DWNL." /></figure><p>Now as mentioned earlier, you now have to make some changes to database.yml. You may also want to ensure if ‘md5’ METHOD is configured to be used in pg_hba.conf for IPv4 and IPv6 connections. Refer to below screenshot and commands at the end of this blog if not clear.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dsp29xBjrILWdg9P." /></figure><p>Browsing towards the end will show you what METHOD is used. Change it to md5 in case it is not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*98WDMD-uYfsQdYOa." /></figure><p>Now, change your database.yml to look like below :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*n4dBKVOAQrxkMdWO." /></figure><p>Now you have to set up users and privileges on postgres db. So follow below commands and procedures.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DLq-Q1Dj8ET7qjdF." /></figure><p>Basically you are logging in as postgres which is the default superuser or admin in postgres context. And ubuntu is the default user created or you can create with a different name but then you will have to change it in database.yml. So I’d suggest stick with the one in my blog for now to avoid any confusion. ‘Ubuntu’ is the default user when we created workspace on Cloud9.</p><p>Now we can create databases as per rails convention — dev, test and production. You can either create dbs manually or using rake utility, I prefer manually when I create role. So once you follow this, you are free to go to the project directory now. Here you run rake db:setup in case you did not set up db manually.</p><p>After initial setup is done, run rake db:create db:migrate. It’ll give you message saying db already exists if you have created already. Then you can spin up rails web server. You can see commands below :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5qtxbvoP2pbSR46V." /></figure><p>Now your rails app is up and running, you can check response to port 3000 using curl or even open it in your browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sfWR40d6ZytCJJFO." /></figure><p>As you can see response status is 200 and also check other details.</p><p>This is the generic setup instructions for a newly imported rails app from another workspace. You can even set up it on your local machine on Fedora or other OS. Since I have to work on my machine, I also set up the PgAdmin GUI for Postgresql as it is not possible to use postgresql shell prompt for everything.</p><p>Here is the whole command script for all of the commands run in above tutorial.</p><p>git clone <a href="https://github.com/askaway/askaway.git">https://github.com/askaway/askaway.git</a></p><p>ruby -v</p><p>rails -v</p><p>gem install bundler</p><p>bundle install</p><p>sudo apt-get update</p><p>sudo apt-get install postgresql postgresql-contrib</p><p>sudo su — postgres</p><p>— CREATE ROLE ubuntu LOGIN password ‘ubuntu’;</p><p>ALTER USER ubuntu WITH PASSWORD ‘ubuntu’;</p><p>CREATE DATABASE askaway_test OWNER ubuntu;</p><p>CREATE DATABASE askaway_development OWNER ubuntu;</p><p>CREATE DATABASE askaway_production OWNER ubuntu;</p><p>GRANT ALL PRIVILEGES ON DATABASE askaway_test TO ubuntu;</p><p>GRANT ALL PRIVILEGES ON DATABASE askaway_development TO ubuntu;</p><p>GRANT ALL PRIVILEGES ON DATABASE askaway_production TO ubuntu;</p><p>ALTER USER ubuntu WITH SUPERUSER CREATEROLE CREATEDB REPLICATION;</p><p>psql -d postgres -U postgres -h localhost</p><p>rake db:setup db:create db:migrate</p><p>curl -X HEAD -I <a href="http://0.0.0.0:3000/">http://0.0.0.0:3000/</a></p><p>Just for the purpose of showing these steps can be followed on any other linux distros, with only a little different commands like instead of apt-get on Ubuntu, you’ll run yum or dnf on redhat, centos, fedora etc, I’ll post some screenshots from my Fedora set up of the same project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nK6Y6RjVy0Iux3s3." /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YMCtBuPgMYYH9Y_K." /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CSw1pcwqDJ9aWzPS." /></figure><p>Hope you all enjoyed this blog, do let me know what you think of this and also anything if I’m doing wrong.</p><p>Enjoy Rails!</p><p>Note : I live in Bay Area and I am actively looking for full-time opportunities as a Software Engineer. If you have any roles for me, you can reach out to me at <a href="/service/mailto:mishra.akshay91@gmail.com">mishra.akshay91@gmail.com</a>. You can find me on LinkedIn at <a href="https://www.linkedin.com/in/akshay-mishra/">https://www.linkedin.com/in/akshay-mishra</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3f1323ea65f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>