Posts tagged ruby

13 notes

Good Talk on how to think about Application Architecture

Micah Martin and Robert C Martin, give a great and entertaining talk on how they worked through building an application. They built the application in the context of abstracting the UI and Data Layers, then focusing on the Business Logic layer, with TDD they were able to build the entire business logic layer, then the connect the data layer, and finally the UI Layer.

Often times we get bogged down in our tools and methods and tend to jump first to use these tools, without thinking about the whole problem. I need to spend more time focusing on the api or design of each module with the abstraction of UI and Data. This approach will continue to deliver better software, time and time again.

The Martins also produce a great collection of screencasts that focus on “Clean Code”. http://cleancoders.com, if you want to architect your software better, and write better code, check these videos out.

Filed under ruby cleancode programming software architecture

25 notes

Ruby Sequel Toolkit - MSSQL with (TinyTDS) - Connect to legacy databases

Connecting to MSSQL from ruby has always been painful

UnixOdbc, FreeTds, and TinyTds has really made the connections super easy.

Using the Ruby Sequel Toolkit, you are able to create an active model like interface to legacy databases which may not follow the active record standards.

class Store < Sequel::Model(:csstore)
  plugin :validation_helpers
  set_primary_key :store_id 

By specifying the real table name in the Sequel::Model declaration, you can call your class whatever you want.

dataset.disable_insert_output! - Is not necessary for every model, but if you have a table that is using triggers, you may want to add this line in your model. SQL 2008 returns and error when trying to call an insert or update statement with OUTPUT and no INTO.

set_primary_key - You can connect to any table, with any kind of primary key name, all you have to do is call the set_primary_key method with the name of the primary_key.

Recently a Ruby Sequel Rails 3 gem update was released, it should now be easier than ever to create a Rails 3 app and connect to a legacy MSSQL Database!

Filed under ruby mssql sequel toolkit

2 notes

Code School - Rails Best Practices Review

The Code School ‘Rails Best Practices’ Super Deluxe Championship edition had me hooked from the beginning with the references to 1980’s arcade games. The videos were so entertaining to watch that I could not stop until the course was done. Taking the time to review concepts that are already familiar never hurts any one. The First 3 levels were exactly this. After progressing past the 3rd level (The challenges could have been a little more difficult.), I started to pick up a few new tricks that I have begun to use in my day to day coding. Learning about delegators and presenters was helpful. The try method has helped me clean up some ugly nil checks in views. No matter what level the rails developer, this course is worth going through.

Gregg Pollack does such a great job of keeping it entertaining, you can not help but pay attention and learn something new or just brush up on your existing skills. I would definitely be interested in taking more courses from Code School.

Kris Windham

Jack Russell Software

Filed under ruby rails codeshool

13 notes

html2haml.heroku.com up 670.01%

What a difference a year makes, html2haml.heroku.com was launched on 05-31-2009, and really picked up steam in October 2009. Almost 200 developers daily are using the simple tool to help convert html to haml.

Is haml picking up traction?

Recently, there was a solid debate between erb vs haml, on the new podcast Ruby Rogues.

On the show, the preference from Haml or Erb was split down the middle and both sides made compelling arguments.

More than just Ruby Users

So many other languages and frameworks have adopted the usage of haml.

What is the best? (Haml or Erb)

I think the debate will continue on for sometime.

It is clear that there are more developers converting html to haml, than a year ago on html2haml.heroku.com. I think HAML is here to stay, whether you love it or hate it. Below are some more stats that are interesting as well.

Thanks again to Hampton Catlin, Nathan Weizenbaum, Chris Eppstein, and numerous contributors to haml and to Heroku for hosting the site.

Filed under ruby rails haml html2haml

2 notes

Code School - Rails Best Practices Review

If you are anything like me visual and hands-on experience are two of the most effect methods of learning. Code School has taken these teaching methods a step further to offers a new intuitive and interactive learning experience through the use of video, slides, and chapter quizes that utilize the in-browser editor. I have taken both of the courses that are currently being offered: Rails for Zombies and Rails Best Practices. Both courses have proven to be quite useful for me seeing as though I am still quite new to Ruby on Rails and coding in general. Rails for Zombies is an awesome low-level ROR overview great for newbs or as a refresher, whereas Rails Best Practices focuses more on refactoring of code, and you guessed it, ‘Best Practices’.

My most recent Code School experience was taking the ‘Rails Best Practice’ course, which I must say is a very useful and well put together course. Throughout the course, I was constantly having ‘A-ha’ moments learning cool new tricks, which I guess is the point. The content layout of the course was well laid out and each lesson was well organized with common themed material. As is the flow of the other Code School lessons, each lesson is followed by some useful hands-on quizes that review that lessons’ material.

In general, the lesson quizes are awesome in that you are able to get in some hand-on experience and utilize new tricks you may have just learned. The convenience of being able to go from the lesson to the lesson quizes and the editor and begin writing code all in your browser window is awesome!! My only aversion being that many of the error logs in the editor we not very helpful in debugging at all. A few times I found myself spending way too much time trying to figure out what was wrong with my code only to find out I had any extra space somewhere.

In all, I found ‘Rails Best Practice to be a great learning tool filled with great information that is delivered through captivating multimedia videos and slides.

  • Russell Niller

Jack Russell Software

Filed under ruby rails CodeSchool

0 notes

Code School - Rails Best Practices Review

I am a big proponent of the learn by doing paradigm and the Rails Best Practices course from the guys at Code School is a really neat way to get familiar with rails development. I really enjoyed the light-hearted yet content packed screencasts that have the usual awesome production values from Envy Labs. I was even more impressed with the exercises at the end of the sections. The slick interface was a joy to use but there were several times where the answer I provided, while “correct”, was not quite what the exercise was looking for and it was hard to tell why. Even though I was familiar with most of the topics covered there were several things I learned that have become a part of my everyday toolkit. I was unaware of the .try and .present? methods and they have helped in making my code more readable. I also learned a lot about the rails counter cache and the subtleties in the methods for getting the size of a collection. Overall I enjoyed working through the sections and I am very excited to see what Code School is able to do with their interactive platform!!

  • Colin Alstad Jack Russell Software

Filed under ruby rails codeschool

0 notes

De-Identify your data or Fakerize your data

Ever need to pull a copy of your production data?

Ever need to create a demo sandbox for your sales team?

We did.

So we created a gem called Fakerize, it is currently going though some internal testing, but we will launch as open source as soon as we have all the issues worked out.

This Command Line Interface, makes it very easy to de-identify your database.

You simply create a config yaml file with a map of all your models and a list of fields that you want to fakerize.

   :name: :patients
       :field: :last_name
       :fakerize: Name.last_name

Save as config.yml

Then install the fakerize gem

gem install fakerize

Then if you have a mysql database run:

fakerize database:convert mysql://user@localhost/mydb config.yml

And it will proceed to de-identify your database.


Now you can push your database to a demo app or just hack on your database locally, but feel better that you are not carrying around your clients liability in your computer.


Just the beginning!

We plan add a feature to allow you to use it for any data store.

Right now, it uses the Sequel Toolkit and can connect to any adapter that the Sequel toolkit uses, but we are planning to allow you to create adapters for any datastore.

Also we plan to add a “database:clean”, that will allow you to specify models that you want completely emptied!

Filed under ruby rubyonrails

13 notes

Testing jQuery Autocomplete using Capybara

Using Selenium + Capybara + jQuery to select an option from an AutoComplete

Have you ever found yourself pulling your hair out at 3:00am, frustrated and challenged beyond all that is humanly possible, because your tests are unable to select any of the options from an AutoComplete?


Lucky you.

But if you have, this quick jQuery snippet, once placed correctly, will hopefully make your late nights of frustration a little bit shorter.

We first find the text field label, “Name”, and fill it in with text that will cause the AutoComplete to show us a list of the result(s) so that we may select one.

 fill_in 'Name', :with => 'Jack'

Moving to the next line, the sleep() is necessary so that the AutoComplete has time to load and have what we want selected. The time count may vary.

sleep 3

Lastly, we tell Capybara to run some script:

  • look inside the ui-menu-item list item class,
  • find the link (denoted by the anchor (a) tag) that has “Jack Russell Software” in it,
  • use the .trigger() function to simulate your mouse entering the AutoComplete field (different version of .mouseenter() http://api.jquery.com/mouseenter/), and
  • click on the selected field.

    page.execute_script ” $(‘#{selector}’).trigger("mouseenter").click();”

May your days (and nights) of testing AutoCompletes be fruitful.

Robert Pearce

Jack Russell Software Company

Filed under ruby rails rubyonrails

0 notes

Ruby Syntatic Sugar

Reviewing the page it looks like it has a lot of useful functions, but I really like the plugin component of the gem and how everything can be include by using the require, even by versions.

This is definitely something to add to the list.

Filed under ruby