Tag Archives: ruby on rails

January 2013 Meetups: TypeScript, Riak, .NET, JavaScript… re: Calagator

Here’s a few of the meetups I’m going to aim to attend this month. Hope to see some fellow coders there.

PADNUG…

…is having a TypeScript Introduction. There’s a lot of those made up marketing words thrown around in the description such as “Application-Scale JavaScript Development”. Maybe TypeScript is magic, but overall it seems to be suspicious. Also, this talk is about how TypeScript will help you write Windows 8 Apps, so you’ve been warned. The kool-aid will be in effect. If you want to learn more about it, go check out the PADNUG meetup on January the 8th at 6:00pm. Intel Hawthorn Farms 3 (HF3) Campus, 5200 NE Elam Young Parkway, Hillsobor, OR 97124.

Portland Ruby Brigade…

…is having their regular monthly meetup at Crowd Compass. If you want to know more about the topic, material or other information about the user group jump into the Google Group to get started. This is a very fluid and flexible group, sometimes having an open discussion, a presentation or some other type of event. Crowd Compass, 2505 SE 11th Ave, #300, Portland, OR 97202. The location is in the Ford Building, with the easiest access straight in to the Ford Food & Drink.

Portland Riak Users Group…

…will meet at AppFog (as of this time) at 6:30pm on January 28th, more info & address on the meetup page. We have a coder/hacker/databaser by the name of Jeremiah Peschka @peschkaj coming in to tell us about the open source project he and OJ @TheColonial have been working on called Corrugated Iron. Corrugated Iron is a .NET Client for Riak, so holds a lot of potential for .NET shops to get into the distributed database world. So come check out the meetup, we’ll be having pizza and likely a bucket full of beer!

There are others, but these are the events that caught my eye. Check them out, I might see you there and if not, let me know how they go. If you’re looking into some other meetups or events, check out Calagator, the Portland Tech Scene Calendar of events.  🙂

Basho – First Week Coding & Research Adventures…

The First Things

This week, the first thing I did was give a solid read to Mark Phillip’s Blog “themarkphillips” (@pharkmillups). Here’s a break down of some entries I found really interesting and helpful in getting kick started here at Basho (or just really a good read in and of itself):

  • Using Open Source to Promote Sustainable Farming – Mark got to interview Chris Villalobos @frostbytten a long while back, but ended up getting a good interview and also got Chris to write an article on the Basho Blog “Riak in Production – A Distributed Event Registration System Written in Erlang”. Chris was working on Open AgroClimate Project a climate information and decision support system for managing agricultural and natural resources in the Southeastern US. Pretty interesting articles, the whole lot of them.
  • Two Anecdotes About Community From JSConf and NodeConf – This is a great one, two anecdotes that I’m all “hell yeah” about. The entry caught my eye for the obvious reasons that the whole great team behind JSConf & NodeConf, I always have to read about. Mikael, Chris and the whole lot of Noders are a great crew of people, throwing absolutely great conferences. The two anecdotes; “You Want Your Users To Hug You” andMeeting People In Real Life Never Gets Old And Is Incredibly Valuable”.
  • Another great entry revolved around putting together RICON 2012. See my other entries “RICON2012 Shreds the House!” and “RICON 2012 Photos” for more on RICON. This entry really lays out ground work for the mission Mark Phillips, Tom Santera and the rest of the team I’ve joined at Basho have to grow the community that works with, around and building distributed databases and systems.
  • The latest entry, the entry key to what I’m tackling, is the “Month One for Technical Evangelists at Basho“. This leads me to the next blog & entries and material I needed to dive into.

The next blog I gave a good review of was the Basho Blog.

  • Riak Cloud Storage with Multi-Datacenter Replication – this blog entry outlines the release of, well, what the title says. This release though, is a pretty big deal. The storage is already S3 compliant, a huge benefit in the first place. The entry goes into some detail about the full and realtime sync capabilities of the system. However if you’re really interested in this there’s more to dive into – so ping me or jump on the Basho mailing list and strike up a conversation. We love talking about this stuff at Basho, so don’t shy away from throwing some conversation our way.
  • The next blog entry that caught my attention, since some of my first demoes are going to be JavaScript, Node.js and Riak, the project around Riak.js getting a fresh start was a relief to read. I’ll admit, I read it when the blog entry was published. 😉
  • One last entry I read, then dived into the content that it links to is the “Building Apps on Riak” content and use cases blog entry. It links to the Basho Docs (see below) and use cases page.

The last two major things that I read, which are really important in the field of distributed databases and also having a work culture that seriously rocks. These two papers are the Amazon Dynamo Paper and the Valve Handbook.

amazon-dynamo-sosp2007 & Valve Handbook

The second thing I wanted to do was get Riak setup on my local machine to play with. I’d setup Riak a few times before in a multi-node cluster using Tier 3′ s Blueprint Technology to automate the process. This time however I’m taking the vantage of installing it locally for use. So what’s the steps? Well, it’s pretty straight forward. First however, I wanted to synch up my first install experience with the Basho Docs. Since the documentation is actually available via your standard open source repository on github, the Basho way, I wanted to get a local running copy of it.

Basho Documentation

I wanted to business, not just to read but also to contribute back to the basho_docs. This isn’t just some filler docs either, they’re actually really useful and well written. In other words, it’s solid, updated and well maintained documentation.

I forked the basho_docs to my own repo and went to work setting it up. Everything was going great until I stumbled into blockenspiel, or so I thought it was blockenspiel. Thus, the adventure of crazy new machine forgetfulness begins.

Breaking blockenspiel

I’ve spent a couple hours trying to get middleman working for the basho_docs project. Why did I spend a few hours working on this? Well the obvious one is I wanted to get the docs up and running locally, ya see, I intend to contribute back (want to jump into them too, hit up the github repo). While I was getting these installed I made a few mistakes and ran into a few issues. Here’s the story.

The first thing I forgot was to install rvm. The basho_docs project uses rvm and I highly suggest you use it, or something like it. In this case the project has specific settings you definitely want. The simple reason I didn’t have it is that I’d forgotten that I hadn’t installed it on my new Mac Book Air! Doh! Easily fixed via https://rvm.io/. While there I also installed the Jewelry Box App, it’s pretty decent, but you’ll still want to dive into the command line where the real power is.

So with that all good I got through the next few steps.

$ gem install bundler
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /Library/Ruby/Gems/1.8 directory.
Adrons-MacBook-Air-2:basho_docs Adron$ sudo gem install bundler
Password:
Successfully installed bundler-1.2.3
1 gem installed
Installing ri documentation for bundler-1.2.3...
Installing RDoc documentation for bundler-1.2.3...
Adrons-MacBook-Air-2:basho_docs Adron$ bundle install
Fetching gem metadata from http://rubygems.org/.......
Fetching gem metadata from http://rubygems.org/..
Enter your password to install the bundled RubyGems to your system:
Using rake (0.9.2.2)
Using i18n (0.6.1)
Using multi_json (1.3.6)
Using activesupport (3.2.8)
Using builder (3.1.3)
Using mime-types (1.19)
Using xml-simple (1.1.1)
Using aws-s3 (0.6.3)

At this point, the install seemed to be going great, and then BOOM, this happened!

Installing blockenspiel (0.4.5) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h

Gem files will remain installed in /Users/Adron/.bundler/tmp/13504/gems/blockenspiel-0.4.5 for inspection.
Results logged to /Users/Adron/.bundler/tmp/13504/gems/blockenspiel-0.4.5/ext/unmixer_mri/gem_make.out
An error occurred while installing blockenspiel (0.4.5), and Bundler cannot continue.
Make sure that `gem install blockenspiel -v '0.4.5'` succeeds before bundling.
Adrons-MacBook-Air-2:basho_docs Adron$ gem install blockenspiel
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /Library/Ruby/Gems/1.8 directory.
Adrons-MacBook-Air-2:basho_docs Adron$ sudo gem install blockenspiel -v '0.4.5'
Building native extensions. This could take a while...
ERROR: Error installing blockenspiel:
ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h

Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/blockenspiel-0.4.5 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/blockenspiel-0.4.5/ext/unmixer_mri/gem_make.out

Ok, so maybe I shouldn’t have used sudo, but wasn’t sure what the permissions issue was in the first place. Yeah, that’s a bad idea just to barge ahead, but sometimes you gotta just move on things. Maybe that was or wasn’t the issue. I didn’t know at this point so started to do some research.

The first thing I realized, was barely anyone had run into this issue. I did however find two things that seemed like they may be the root cause of this blockenspiel problem.

https://github.com/dazuma/blockenspiel/issues/4 which shows the native extension not building and a bug is issued here http://bugs.ruby-lang.org/issues/4803. Ugh, how frustrating. Then I also noticed something else, the build is not passing per the README.md file displaying the Travis CI status.

That sux, but I kept digging at that point.

So which native extension did I need to install? I was missing it for some reason. Then I dug around a little more and discovered this in one of the logs.

[2012-12-07 09:50:07] ./configure --prefix=/Users/Adron/.rvm/usr
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... config/install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/Users/Adron/.rvm/src/yaml-0.1.4':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details

Hmmm, dammit, new machine mistake again. I needed a C compiler ASAP! Opening up XCode I immediately got this fixed by installing the CLI tools. These tools include about a zillion things I obviously needed, including the LLVM Compiler, Linker and the universally needed Make.

XCode CLI Tools Installation, for full size image click.

XCode CLI Tools Installation, for full size image click.

Ok, I finally got that installed and moved forward again. Pulled down the bits, and ran smack into the problem again. The blockenspiel lib can’t build the native extension. Ugh! However this time I got a slightly more useful error message at least.

/Users/Adron/.rvm/rubies/ruby-1.9.3-p327/bin/ruby extconf.rb
checking for ruby/backward/classext.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
	--with-opt-dir
	--without-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/Users/Adron/.rvm/rubies/ruby-1.9.3-p327/bin/ruby
/Users/Adron/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:369:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
	from /Users/Adron/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:494:in `try_cpp'
	from /Users/Adron/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:919:in `block in have_header'
	from /Users/Adron/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:778:in `block in checking_for'
	from /Users/Adron/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:272:in `block (2 levels) in postpone'
	from /Users/Adron/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:242:in `open'
	from /Users/Adron/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:272:in `block in postpone'
	from /Users/Adron/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:242:in `open'
	from /Users/Adron/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:268:in `postpone'
	from /Users/Adron/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:777:in `checking_for'
	from /Users/Adron/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:918:in `have_header'
	from extconf.rb:44:in `'

My first thought was, WTF didn’t I just install the developer tools?

Went digging for this problem and found this interesting and likely related Stackoverflow Entry “”. One of the suggested solutions would be found in executing the following commands. As I read this I realized it wasn’t the marked answer, but I needed MacPorts so I downloaded MacPorts! A quick few seconds later I grabbed it and tried out these commands just to at least get things updated.

sudo xcodebuild -license
sudo port upgrade outdated
sudo port install apple-gcc42
sudo rvm reinstall 1.9.3

At this point, still no go. I was getting pretty pissed. At least I was getting all these things setup on my machine, but seriously, this should NOT be this hard. The next thing I did was also update my Ruby Gems, as another place on the web suggested doing that. I tried installing middleman again.

gem install middleman

At this point I was a bit frustrated, sat back and figured, I’ll give it a go in a while. Well after a few hours to let things sort out in my head, I picked up a completely different laptop. My Mac Book Air I’ve had and been using for over a year now. I opened up iTerm2 and through these commands in bash:

git clone https://github.com/basho/basho_docs.git
gem install bundler
bundle install
middleman

…and the server started right up on port 4567. I opened up a browser and navigated to http://localhost:4567. Right there before my eyes loaded the Basho Riak Documentation!

After all that, it boils down to some stupid machine load issue. So I’ll come back to fixing that machine some other time. For now, it was finally time to move on to other things. But that’s a gist of week one, and week two will be starting in just about 47 minutes. Next week I’ll be diving in a bit more to all of these things plus some actual installation, setup and related skill with Riak. Until then, cheers.

Adam & Krishan Got Me Motivated Today… to toss the trash conversations

I was speaking with Krishan Subramanian (@krishnan) and Adam Seligman (@adamse) today. I love talking to these guys. They’re both smart, intelligent and upbeat guys. They see the positive things we’re all working toward and accomplishing in the technology space, specifically around PaaS, Cloud Computing and around the cultural implications of stronger technology communities, involvement of individuals. We all can see the positives, of how the industry is moving forward so that corporations aren’t the only enablers that are juxtaposed against developers or consumers but instead act to serve consumers based on the progress that individuals make themselves. There’s so much to do and so much progress to be made, the venders can simply follow the community and step up to provide points of leadership.

Absolutely great talking with these guys…

On that topic, what is it that we discussed that has me so motivated? Well there’s a few things that I’m done with and I’m going to make every effort to just throw away the trash. Here’s a few of these things that we discussed and I challenge everybody out there, drop the trash talk and let’s move forward because there is a LOT of awesome things to accomplish. Here’s the two things I’m just dropping…  cold. No reason to discuss them anymore.

  • Toss the language and framework religious wars. It is far simpler than it is sometimes perceived. We have a polyglot industry now where we can easily use the right tool for the job, the right framework, or the language that handles our particular domain the best. There is literally no reason to argue about this anymore. Of course we can talk semantics, debate best use cases, and of course we’ll talk accomplishments and what various things do well. That’s exactly what the focus should be on, not the harping on my X is better than your Y nonsense.
  • The culture war is basically over. Sure there are the hold outs that haven’t gotten a clue yet. But it’s an open source world at this point. Even the dreaded and horrible Oracle has generally conceded this and is frantically waving its marketing arms around trying to get attention. But at the core, mysql, java and the other things that they’ve purchased they’re keeping alive. They’re active participants in the community now, albeit in a somewhat strange way. Considering that even Oracle, Microsoft, Apple and so many others contribute back to the open source community in massive ways, that war can be considered won. Victory, the community and every individual in that community!
  • Lockin is basically dead. The technological reasons to lock in are gone, seriously. There’s some issues around data gravity that are to be overcome, but that’s where a solid architecture (see below) comes in. Anything you need can be contributed to and derived from the development community. Get involved and figure out how technology can be a major piece of your business in a positive way. If you design something poorly, lock in becomes a huge issue. Use the rights tools, don’t get into binding contracts, because in the polyglot world we’re in now there’s no reason to be permanently locked in to anything. Be flexible, be where you need to be, and make those decisions based on the community, your support systems, and your business partners. Don’t tie yourself to vendors unless there is mutual reasons to do exactly that. Lock in is a dead conversation, just don’t, time to move on.

So what are the key conversations today?

  • Ecosystem Architecture – If you’re deploying to AWS, Heroku, Tier 3, AppFog or Windows Azure it all boils down to something very specific that will make or break you. Your architecture. This is where the real value add in the cloud & respective systems are, but there are many discussions and many elements of the technology to understand. This is a fundamentally key conversation topic in the industry today. Pick this one up and drop the other trash.
  • Movement & Data Gravity – How do you access your data, how do you store it, where and how do you derive insight from that data? This is one of the topics that came up in our discusssion and it is huge. The entire computer industry basically exists for the reason of insight. What should we eat today, how do I shift my investments, how is my development team doing, what’s the status of my house being built, where is my family today and can I contact them! All of these things are insights we derive from computer systems. These are the fundamental core reason that computers exist. As an industry we’re finally getting to a point were we can get some pretty solid insightful, intelligent and useful information from our systems. The conversation however continues, there is so much more we can still achieve. So again, drop the wasteful convo and jump on board the conversations about data, information and insights!
  • Community Involvement – I’ve left the key topic for last. This is huge, companies have to be involved today. Companies aren’t dictating progress but instead the community is leading as it should. The community is providing a path for companies to follow or lead, but the community, the individuals are the ones that are seen and known to be innovating. This is so simple it’s wild that it is only now becoming a known reality – companies don’t innovate, people do. Companies don’t involve, people do. Individuals are the drivers of companies, the drivers of Governments, they’re the ones driving innovation and progress. The focus should now and should have always been on the individuals and what they’re working toward to accomplish. So get involved, get the companies involved as a whole and keep the semantic ideal of individuals and the progress they can make core to the way you think of communities. The idea of the “company” innovating is silly, let’s talk and build community with the people that are working around and innovating with these technologies.

Of course there are more, I’d love to hear your take on what the conversations of today should be about. What do we need to resolve? How do we improve our lives, our work and the efforts we’re working toward on a day to day basis?

Your Bus Is NOT Here! But We’re Working On It…

But myself and fellow hacker & Geoloqi Crew put something together to figure out where the bus is. Nothing super fancy, but the idea is solid. We wanted to get a simple mobile application put together that would identify where it is, what the closest bus stop is, and pull up the next arriving bus(es) for that stop. We were throwing in a few other ideas, such as pulling up specific stops based on your favorites or even specific buses at that route based on your preferred routes.

Pat (@patrickarlt) & I (@adron) started out by pulling in the GTFS data from TriMet. I setup a basic import to turn all the stop locations in the GTFS data into a Place within a layer within Geoloqi. Pat setup a URL that could be used to call down the latest X arriving buses. Then we combined forces figuring out how to efficiently get all of the 7000+ bus stops into Geoloqi. That proved a little bit more of an issue than we thought. Not a huge issue, but one that got Kyle (@kyledrake) and Aaron (@aaronpk) Coding some fast batch solutions to get it all into Geoloqi while Pat & I handled the application.

On Sunday we’re lined up to get the application into a MVP (Minimally Viable Product) state. We’re hoping to be able to maybe even use it tomorrow in at least a simple way. From that point forward we’ll hopefully move past the MVP into other functionality! 🙂

Another thing to note, is that with our basic implementation we’re using GTFS data. This is a data format that is standardized and used by many of the agencies around the country. So technically any transit agency, as long as they have a way to return their route arrivals, can be setup to use our application we’re building. Some of the other GTFS data can be retrieved here;

To check out more, hit up Google’s page on GTFS data sources:  http://code.google.com/p/googletransitdatafeed/wiki/PublicFeeds

Day one of the hackathon has been seriously kick ass! I’ve had a blast and heard some great ideas, seen some great code, even working demo results, and seen amazing skills applied all around! At this juncture, I’m exhausted, got a little more to code, and ready for day 2 of hacking!

Ruby on Rails Hittin’ The Big Time, A Friday PSA

How do you know that Ruby on Rails has already hit the big time?  Not that it needs anymore proof that it is absolutely one of the MAJOR platforms available right now…

  1. Recruiters now regularly come to user groups & offer to “buy the beer” afterwards.
  2. The split of job searches on sites now easily come up with dozens upon dozens of Ruby on Rails Jobs.
  3. Enterprise & Other Managers are commonly asking what the “Ruby on Rails Dev Base” looks like.  In other words, they want to know who and how many people they can hire.
Anyway that you look, you’ll see Ruby on Rails making inroads at a company near you! Keep your eyes peeled, and if you aren’t polyglot now, you might want to start thinking about it.
Cheers!  Happy disruptive markets to you!  😀

Keeping Your Rails Projects Organized Right!

I’ve been working with Rails now for about 3 months. At first I jumped right in like a bull in a china shop. I have since, suffered the frustration of doing so. I’ve experimented on OS-X, Windows, and Linux (primarily the Ubuntu Distro). Among these three operating systems, getting up and running with rails is a breeze. Sure, I’ve wrecked more than a few apps I started, blown to smithereens a few machine images, and been generally destructive – but that’s not a bad way to learn at all. 😉

Through this trundling, I’ve come to find there are a few things that should be reviewed and learned thoroughly before smashing into the china shop (i.e. rails or Ruby for that matter). One of these tools is RVM. Another is Git. These tools, without doubt or question, you MUST LEARN! There is just too much value in both of these tools to try to ignore either one. First a quick description of each:

Git – Git is a source control server and respective client software.
 
RVM – Ruby enVironment Manager – RVM, sometimes referred to as the Ruby Version Manager also, is a way to maintain the various gems and other environment settings that are used for a particular project. It enables switching back and forth between versions of ruby, keeping ruby updated, and much much more.  In .NET, think of it as choosing which version of .NET to use, except with more power to go beyond just merely choosing which version. These two tools are pivotal in having a smooth, consistent, and understandable workflow. There is one other issue for Windows users here though, RVM does not and will not ever run on Windows. One can however install cygwin to get it running or they can use Pik.

Workflows

Below I have a short workflow tutorial, which I’ve broken out to getting started, working, and operational.

Getting Started

This is the first stage of any development project. Regardless of using PHP, Rails, .NET, Java, or whatever, there are certain things that need done. The key elements that I’ve found over the years include, not in any particular order;

  • Setup source control
  • Setup your environment
  • Start your basic project
After each of these things are done, and working together properly, it’s time to get coding. 🙂  First, setup a directory that will be the home for the entire project.
$ mkdir sampleWorkflow

Next run the command to setup your environment for this specific project.

$ rvm --rvmrc --create 1.9.2@sampleWorkflow
$ cd ..
$ cd sampleWorkflow/
==============================================================================
= NOTICE                                                                     =
==============================================================================
= RVM has encountered a new or modified .rvmrc file in the current directory =
= This is a shell script and therefore may contain any shell commands.       =
=                                                                            =
= Examine the contents of this file carefully to be sure the contents are    =
= safe before trusting it! ( Choose v[iew] below to view the contents )      =
==============================================================================
Do you wish to trust this .rvmrc file? (/Users/adron/a_code/sampleWorkflow/.rvmrc)
y[es], n[o], v[iew], c[ancel]> yes
$ ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]
$

In the command above, rvm being the application, –rvmrc the parameter for what is being done, and –create is the command for the action to be taken. The 1.9.2 before the @ is the Ruby version and the value after the @ is the environment name, in this case being the same as the folder.

Once the command is run, move out and back into the folder to view how the rvmrc file will work. When you navigate into the directory again, the script will run, initiating the environment for Ruby 1.9.2. It will also ask to confirm if you trust the file. Running the ruby -v command to determine the version, will now display the active ruby version for this folder.

If you’re only using one version of Ruby, this might not seem that useful. But over time as you work with multiple projects, you will often find that different projects use different versions of Ruby. Sometimes 1.8.7 or jruby or rubinius. If that’s the case, rvm is a life saver in simplifying and keeping environments neatly organized.

Now that the environment is setup, we’ll need source control setup and as I generally prefer, an initial commit. Make sure to move into the directory that was just created. Issue the following git commands.

$ git init
Initialized empty Git repository in /Users/adron/a_code/sampleWorkflow/.git/
$

With our directory now intialized for git, it is best to get a git .gitignore file created. (I know, that’s a lot of get gittin). Use mate, or whatever your editor is you prefer, and create a .gitignore file.

$ mate .gitignore

At this point you’ll want to add something to the ignore file. I always start with the following basic files and folders to ignore. I’ve also written a short entry on what these files and folders are that I’m ignoring in the post Gotta Get Git.

#OS junk files
[Tt]humbs.db
*.DS_Store
.sass-cache/
.bundle

#Webstorm & Rubymine files
*.idea
.idea
.idea/

#Rails Heroku and other bits to ignore
*.sqlite3
db/*.sqlite3
public/system/*
.bundle
log/*.log
tmp/**/*
tmp/*
doc/api
doc/app
*.swp
*~

Once that is entered, save the file and close. Next we’ll do our first commit. This is always a good practice, then there are no accidental commits of files that aren’t needed. Also note, I did not exclude the rvmrc file, this is needed to insure clarity about the environment when cloning the repository in the future.

$ git add -A
$ git commit -m 'first commit'
[master (root-commit) ea81bed] first commit
 3 files changed, 131 insertions(+), 0 deletions(-)
 create mode 100644 .gitignore
 create mode 100644 .rvmrc
 create mode 100644 .rvmrc.10.29.2011-11:33:32
$

Now that this is recorded in source control history (not of course in the main repo, we’ll do that in a second) I like to go ahead and create the rails application. Move to a directory just below where the ‘sampleWorkflow’ directory is and create a rails application named the same thing. Since we already created the .gitignore file, we’ll be prompted to overwrite, which isn’t needed since the .gitignore is already setup correctly.

$ ls
sampleWorkflow		someOtherAppOrSomething
$ rails new sampleWorkflow
       exist
      create  README
      create  Rakefile
      create  config.ru
    conflict  .gitignore
Overwrite /Users/adron/a_code/sampleWorkflow/.gitignore? (enter "h" for help) [Ynaqdh] n
        skip  .gitignore
      create  Gemfile
      create  app
      create  app/assets/images/rails.png
      create  app/assets/javascripts/application.js
      create  app/assets/stylesheets/application.css

…more stuff shows up…

 create  tmp/cache
      create  tmp/cache/assets
      create  vendor/assets/stylesheets
      create  vendor/assets/stylesheets/.gitkeep
      create  vendor/plugins
      create  vendor/plugins/.gitkeep
         run  bundle install
Fetching source index for http://rubygems.org/
Using rake (0.9.2.2)
Using multi_json (1.0.3)
Using activesupport (3.1.1)
Using builder (3.0.0)
Using i18n (0.6.0)
Using activemodel (3.1.1)
Using erubis (2.7.0)

…more stuff shows up…

Using railties (3.1.1)
Using coffee-rails (3.1.1)
Using jquery-rails (1.0.16)
Using rails (3.1.1)
Using sass (3.1.10)
Using sass-rails (3.1.4)
Using sqlite3 (1.3.4)
Using turn (0.8.3)
Using uglifier (1.0.4)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

…and then when finished do a commit of the recent additions.

$ git add -A
$ git commit -m 'Adding Rails 3.1 Project.'

Now add the appropriate remote sources for git and the project is ready for development.

$ git remote add origin git@github.com:Adron/Kata-Coding-in-Rails.git
$ git remote -v
origin	git@github.com:Adron/Kata-Coding-in-Rails.git (fetch)
origin	git@github.com:Adron/Kata-Coding-in-Rails.git (push)

The example, with extra example code in place, is available on @Github at https://github.com/Adron/Kata-Coding-in-Rails.

Operational

On a regular basis, while coding, one wants to commit their regular work and push those changes to the server (@Github in this scenario). After every change, add the changes to the commit, then commit with a message as shown. When done, do a pull to insure everything is up to date and then a push.

$ git status
# On branch master
# Changes not staged for commit:
#   (use "git add ..." to update what will be committed)
#   (use "git checkout -- ..." to discard changes in working directory)
#
#	modified:   Gemfile
#
no changes added to commit (use "git add" and/or "git commit -a")
$ git add -A
$ git commit -m 'updated Gemfile.'
[master b06aa76] updated Gemfile.
 1 files changed, 0 insertions(+), 1 deletions(-)
$ git pull
Already up-to-date.
$ git push
Counting objects: 5, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 289 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
To git@github.com:Adron/Kata-Coding-in-Rails.git
   6986cd0..b06aa76  master -> master
$

Operational

This section, I’m going to primarily provide a bunch of links to specific instances of features for Git or RVM.

Git Branching

$ git checkout -b modify-branchSwitched to a new branch 'modify-branch'$ git branch  master* modify-branch

…make some changes…

$ git add -A
$ git commit -m 'committing a minor readme.md file change while in a branch.'
[modify-branch 726e770] committing a minor readme.md file change while in a branch.
 1 files changed, 3 insertions(+), 1 deletions(-)
$ git push
Everything up-to-date
$ git checkout master
Switched to branch 'master'
$ git merge modify-branch
Updating b967d4e..726e770
Fast-forward
 README.md |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
$ git branch -d modify-branch
Deleted branch modify-branch (was 726e770).
$

Git Rebasing

Git Stashing

Managing Gemsets

Last Night’s Cafe Racer Ruby on Rails Meetup; Kilt Lifter, EngineYard, Heroku and a Ruby Tone

Yesterday evening at the Cafe Racer Ruby on Rails meetupI knocked out these specific tasks.

Kilt Lifter by Pike Brewing Company

Kilt Lifter by Pike Brewing Company

  • Drank a solid tasty Kilt Lifter.
  • Created a sample beginning application, with standard migrations, and errata, and made two simple models with respective scaffolding.
  • Deployed the beginnings of a sample application to Heroku.
  • Deployed the beginnings of a sample application to EngineYard.

For Kilt Lifter information, click on the image at the right. If you live in the northwest, you know what’s up with the beer capital of the world (i.e. Portland, and the northwest in general, for info see here or click on the image to the left). We love our beer up here in these parts, we love it with a passion and it shows with more brewpubs, beer options, varieties, home brews, and other flavors than anywhere else in the world. No, I did not mis-state that, the northwest has more than anywhere else in the world, almost by an order of magnitude!  More than Germany, Ireland, England, the East Coast of the US, and the list goes on. So if you’re up for a beer and some coding, or just a beer, head to the northwest! We’ll have a few for ya to taste. 😉

The initial Ruby on Rails Application I created I started with RubyMine from Jetbrains. Simply a File -> New Project -> Rails Application, etc, etc. I worked through some of the issues with fellow rubiests and railers at the meetup. We did run into a confusing and nasty issue with Postgresql. Why was I installing Postgresql you ask? Well I was trying to do a deployment to Heroku, which provides a free shared instance of postgresql. I gotta admit, of all the things that Heroku makes absurdly easy, setting up a database is not one of them. Maybe I’m missing a bit, but I don’t know what the instance of the server is, what the username or password is, or anything of that sort. It isn’t all that intuitive that you have to add the database as an add-on either. At least, it wasn’t to the 3-4 of us that were working on it.

The other problem I ran into was what process I should actually use to install Postgresql. The firsts thing I tried to do was submit the “gem install pg” which ended with a completely wonky description. The error message read as:

$ sudo gem install pg
Building native extensions.  This could take a while...
ERROR:  Error installing pg:
	ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb install pg
extconf.rb:1: command not found: pg_config --version
ERROR: can't find pg_config.
HINT: Make sure pg_config is in your PATH
...

I found a fix, here put together by Graham Ashton. Thanks Graham!

The fix involved simply to add a path variable…

$ PATH=$PATH:/Library/PostgreSQL/8.3/bin sudo gem install pg

Meanwhile I dived into EngineYard and got the application up and running in short order. I have to say I am much impressed by the increased visibility into what’s going on with EngineYard. Heroku seems to hide just a bit too much. Add to that their over-reliance on AWS East and not geographically dispersing the platform, I’m leaning even heavier on suggesting EngineYard for startups and companies that want a cloud provider platform to build to.

Once the applications I’ve been working on get to a certain state, I’ll be providing a write up regarding the applications. However, until then, feel free to follow me on Twitter and Github or jump in fork my code and send me a pull request.  🙂

Update: Just some images from the meetup.

Ruby on Rails meetup at Cafe Racer - Corner Table

Ruby on Rails meetup at Cafe Racer - Corner Table

Ruby on Rails Meetup at Cafe Racer

Ruby on Rails Meetup at Cafe Racer