RubyFlow : The Ruby Community Blog

Home   Submit   Sign Up   Log In   leaders   Twitter   RSS Feed  

MetaSkills — 50 posts

Do you want to use your existing Rails' layouts & business logic for your new Blog? Do you know and love Jekyll, but cant seem to get the two to play nice together?
What if you are working on a rich JavaScript application that is backed and tested by something like a Rails application and you want to alter the test browser's clock?
Just a reminder that in Rails 4, ActiveSupport::TestCase will now subclass MiniTest::Spec. This means you will get all the benefits of Test::Unit style assertions with the flexibility of a spec syntax and added spec assertions. But why wait?

You can future-proof your Rails 3 tests and start using MiniTest::Spec now! No changes to existing code! No generators! Just install the minitest-spec-rails gem. This gem tricks ActiveSupport into subclassing MiniTest::Spec. So start reducing the barrier to upgrade to Rails 4 now!
Yea, about JavaScipt, but yesterday DHH was tweeting again about pushing HTML back from AJAX responses since they do not like logicless templates. But they do not have to be. Here is an article called View Controller Patterns With Spine.JS & SpacePen that explores Apple design patterns for ViewController that play out nicely with Spine.JS and SpacePen. Perhaps these methods can be applied to other MV* JavaScript frameworks?
StoreConfigurable - A zero-configuration recursive Hash for storing a tree of options in a serialized ActiveRecord column which includes self-aware hooks that delegate dirty/changed state to your configs owner.

Along with a blog article on it's usage of recursion and hash defaults in Ruby.
As the author of less-rails and less-rails-bootstrap, I would love to explain why you should not be using LESS and Sass instead.
Helpful hacks for Guard::Jasmine to pretty print objects console.log objects to the terminal window. The forth part in my series on testing Spine.JS with Jasmine on top of a Rails application.
Rails & Spine.JS Series
I have just published the first 3 parts of a ongoing series of my experiences using Rails and Spine.JS for a complete rewrite of a personal project: Using The CoffeeScript Source, Jasmine Testing Part 1, and Jasmine Testing Part 2
Yes, sometimes it may be OK to render your CoffeeScript files using the --bare option. Most notably, in test spec helper files under Jasmine. I give to you the sprockets-blackcoffee gem.

An old ActiveRecord extension that I just updated to work with ActiveRecord 3.1. GroupedScope provides an easy way to group objects and to allow those groups to share association collections via existing has_many relationships. It also maintains existing existing scopes, association extensions and options defined in your original collection association. Some new things in this release: (1) Very minimal extensions in ActiveRecord (2) Uses ActiveRecord::Relation and Arel internally (3) Now uses Arel/SQL for the group scope vs. a ton of member IDs.
A review of two new gems, less-rails and less-rails-bootstrap, that make working with LESS and Twitter's Bootstrap in the asset pipeline a dream.
Adding an Object#try_keypath to Ruby that allows you to safely send messages to to deeply nested object structures that may return nil along the way. Based on Object#try.
Wait, what? This is not Oh well. Here is rant on how jQuery missed an opportunity to educate newcomers to JavaScript on what OO JavaScript is all about.
Have you ever had to sleep() in Capybara-WebKit to wait for AJAX and/or CSS animations? A simple code example from HomeMarks v3 which uses Capybara's wait_until block.
jQuery Mobile & Rails
A few helpful hints from my first jQuery Mobile & Rails project. Includes advice on mobile page ids, data attributes, page layouts and testing with Capybara-WebKit.
For those living on the edge and who had this working on 3.1.0.rc4, here is an updated article on a few key solutions.
I just posted a short blog article and my slides on my talk about Open Source, SQL Server & Ruby With Windows.
This article on what the SQL Server Adapter does to leverage ActiveRecord 3.1's prepared statement support should be interesting to anyone interested in DB performance. Specifically SQL Server's plan cache.
A helpful tip if you construct rich JavaScript objects to encapsulate behavior and expect "this" to be your object vs raw DOM elements when using jQuery.
Another in a series of my elegant-hacks™. This one is about how simple it is to use the entire compass Sass framework with the new asset pipeline in Rails 3.1.
For the first time ever, the SQL Server Adapter is ready and waiting for a major Rails/ActiveRecord release while still in beta. If you use the adapter and are interested at all in how we utilize the new prepared statement support, check out this thread on our Google Group and give us some feedback.
A simple working solution for using MiniTest::Spec With Rails by tricking ActiveSupport::TestCase to subclass it. I also discuss using the Rails.backtrace_cleaner and MiniShoulda with Rails too.
MiniBacktrace allows you to take advantage of the Rails.backtrace_cleaner when using MiniTest. This includes everyone using Rails 3 with Ruby 1.9. Just add 'mini_backtrace' to your Gemfile's :test group and your should automatically see a huge difference. Any additions to the Rails.backtrace_cleaner should now work.
I just fell in love with PDFKit and wkhtmltopdf and wanted to cover many topics that I found difficult at first. Specifically page breaks and custom headers and footers. Critical topics while moving from legacy PDF::Writer code.
You can GC tune 1.9.2 with RVM just like Ruby Enterprise Edition. This article walks you through updating and patching your 1.9.2 with RVM. It also covers using RVM hooks to apply your GC preferences. Thanks to Sokolov Yura (funny-falcon) for the patch!
Modern SQL Server & Rails
My guest blog article for Engine Yard on the latest news for those using SQL Server with their Rails applications. It introduces a new connection mode called TinyTDS that replaces our dependence on ODBC.
The road to faster tests is switching to MiniTest. For those using Shoulda, my new gem MiniShoulda is built on top of MiniTest::Spec. My latest post covers some of the details of the new gem and moving to MiniTest.
A simple rake task that uses Heroku's PG Backups addon to push daily backups to your own S3 account.
A journal of my move from Mephisto to Jekyll, a static site generator tailored for blogs. Covers migration of Mephisto data, using SASS, and some HTML5/CSS3 techniques.
Playing around with Tinder/HTTParty to clean up your campfire uploads. Useful if you only care about your textual transcripts and reaching your file limit.
The RVM Ruby API
Recently I started using RVM to setup a CI system for my work on the SQL Server adapter. This article covers my usage of the relatively new RVM ruby API in a rake task that helps setup installed rubies to work with with a MacPorts install base.
How to run JavaScript from TextMate using Safari's SquirrelFish Extreme (SFX) console. The IRB of JavaScript.
Rake is cool. It is built so that multiple tasks with the same name run in a reverse defined series. This is great, but sometimes you want to override a task with your own behavior and conditionally call the earlier task. Especially if that task is defined deep somewhere else, like in a rails gem.
Interested in knowing where your forgery protection is coming from in Rails 3 beta2? Perhaps you want to use these in your RESTful AJAX calls? This article builds on my last one that covers just this info.
Lessons learned from building HomeMarks native iPhone application to synchronize Core Data with a RESTful backend built using rails 3.0.0.pre. This covers a previous design methodology called the AJAX head pattern which decouples rails applications from the views they present which allowed an easy API foundation for the iPhone application and data sync methods.
Well since I now have a rails 3 application in production and more on the way, I starting updating my shell aliases to a new ZSH function that can 'script/console' or 'rails console' depending on my apps setup.
One thing I came across in the current edge rails was using a :method => :destroy option with a standard link_to. My solution to the unfinished UJS in edge rails in this regard.
A solution on how to use both security through obscurity, your own controller access control and finally AWS::S3's own authenticated GETs for private objects all using the popular paperclip gem.
Building on my latest article about the SQL Server stack on Snow Leopard by adding Ruby Enterprise Edition to the mix. Installing REE With The Snow Leopard SQL Server Stack.
This guide is all encompassing but primarily focuses on the benefits of MacPorts, second the development stack for SQL Server and lastly on anything else a rails developer might need on OS X. If you are on a Mac, possibly running Snow Leopard and x86_64 is near and dear to your heart, this article is for you.
PDF::Writer For Ruby 1.9
I recently started tested all my code (work/play) under 1.9 and had the need for legacy PDF::Writer code to pass my tests under ruby 1.9. Some day I'll move to Prawn, but if you want your PDF::Writer legacy code to work under 1.9, have a try at my Github fork of the project.
The SQL Server Adapter for rails is back for ActiveRecord 2.2 and up! We are currently passing all tests and hope to continue to do so moving forward. Includes tons of new features including unicode column support, pessimistic locking, date/time column casting, DDL transactions and more.
I put together a few code themed carving files for the Mac OS X screen saver Jack-O-Lantern from the guys at Killer Robots. Also included are some desktop files for those on Windows. Taking Code-O-Lantern requests.
NamedScope For Those Left Behind: This is not simple hack of named scope like you might find in WillPaginate. This is a fully backported and tested version of NamedScope that will work on rails 1.2.6 or 2.0.4. The most important part of this plugin is that it is TESTED. In fact all the test are Shoulda/FactoryGirl ports of the tests currently found in rails 2.1.1.

This plugin includes backported code for the ActiveRecord class methods that work in conjunction with NamedScope such as first, last and all. This plugin also includes ActiveRecord.attribute_condition which allows you to use named scopes as conditions in other finder methods.
Jack has_many :things is an introductory article for GroupedScope plugin. GroupedScope allows you to extend has_many style associations to use the foreign keys of all the group members. It maintains existing association behavior while allowing new grouped calls that can use existing association extensions and named scopes.
Help me flesh out this project. The Autotest::Railsplugin class aids in the development of rails plugins by using autotest.
HomeMarks was built using the Ruby on Rails framework with a heavy emphasis on object oriented JavaScript to make AJAX requests to a RESTful back-end. Unlike most Rails applications it does not use any inline JavaScript helpers nor does it rely on RJS (Remote JavaScript) for dynamic page updates. Instead it is nearly 100% unobtrusive JavaScript, resulting in slim controller code easily decoupled from the views and testable in isolation at a functional level.

Github project
Hell'OO HomeMarks
The ZombieShotgun module is stoopid code with little practical use if you can edit your own apache conf file... but fun none the less.
RESTful AJAX with Forgery Protection: Just a small code snippet I came up with during the rewrite of HomeMarks. If you are doing any type of RESTful requests with AJAX objects then you might find this little tip useful.
The "The AJAX Head Design Pattern" is the name for the design philosophies driving the rewrite of the application for Rails 2.1. In short the pattern forces the view and controller to work in isolation with the most minimal coupling possible. Kind of like a web service. Long, but videos are included.