RubyFlow : The Ruby Community Blog

Home   Submit   Sign Up   Log In   leaders   Twitter   RSS Feed  
September 10, 2014
Integration tests involving Ruby and JavaScript are fraught with danger. Developers frequently complain of tests which fail erratically. It is possible to write reliable, asynchronous integration tests with Capybara by understanding how Capybara, Ruby, background processes, threads, processes and Capybara drivers such as Selenium, Capybara Webkit, and Poltergeist work, and by following some easy-to-remember guidelines.
The fantastic Devise authentication gem asks registering users for just two items: an e-mail address and password. Chances are you'll want to subsequently gather additional details, such as the user's name or location, typically done through an account profile management form. In this post I show you how this is accomplished.
Floating Point and currency
Why using floating point may be a bad idea when it comes to currency handling and what are the alternatives.
Are you planning to finally bump your app to the Rails 4.1? Then check out my blog post about that. Now with tips about rails 4.1.5!
If you want to master Ruby, you should know strings very well. Follow @RubyStrings to learn about all the details!
September 09, 2014
Introducing RackRabbit - a server that allows you to write your RabbitMQ consumer processes using any Rack compliant framework and load balance multiple instances using a Unicorn-style forking server.
How to set up Continuous Deployment of DNS Records with the help of DNSimple and tools you already use and are familiar with.

This workflow makes changes to your DNS zone transparent and comprehensible for everybody in your team.

DNSdeploy - Continuous Deployment of DNS Records
I've put up a post with the process of applying HTML styles to mailers in Ruby on Rails using HTML Email Boilerplate and Roadie. Check it out at CookiesHQ blog.
After being asked about how to use Fixtures in CarrierWave (the Rails file uploader), I wrote an article about how I'd do it.
The Rails 4.2 announcement had some interesting news about the upcoming Rails 5: It’s probably going to require Ruby 2.2. Which will make it the first Rails version to take advantage of all the good stuff from Ruby 2. The post mentioned garbage collected symbols and keyword arguments. But to me, one of the most interesting Ruby 2 features is Module#prepend.
Kamil Bielawski, one of our Ruby developers, decided to write a follow-up to his previous post, this time about bad parts of Ruby. Do you agree with his picks?
Seems like everyone knows that code review is a valuable tool but a lot of teams struggle with implementing it because of the overhead they feel they just can’t afford right now. Here's why you should do it!.
I just launched Apphera Core, which is the main API for our open source social media monitoring and engagement. Have fun checking it out.
September 08, 2014
Sinatra Cookbook nearly here
As some of you may remember I had a Kickstarter campaign last year to fund the writing of Sintara Cookbook, however I got delayed and not made as much progress as planned, but this week will be lauching the first 8 chapters to buy and sending these to kickstarter backers too.

More information
September 07, 2014
Green Ruby News #83
Bunch of links collected for the first week of september:
September 06, 2014
Hello, The plain text football fixtures for leagues, teams, match schedules, and more that you can read with the sportdb gem into your SQL database of choice (e.g. rake build DATA=es) now includes more 2014/15 seasons e.g. the European Champions League, the Spanish Primera División, the Italian Serie A, and more. Or try the HTTP JSON API e.g. event/cl.2014_15/teams or event/cl.2014_15/round/1 and so on or better build your own HTTP JSON API using the starter kit. All data, code and samples public domain. Enjoy. Cheers.
September 05, 2014
order_query finds next or previous records relative to the current one efficiently, using techniques popularized by Markus Winand. Version 0.1.3 just came out with several performance improvements. Read more on Github.
I published a series of articles about Service Oriented Architecture - discussing the choice between SOA using HTTP vs using a message broker like RabbitMQ. Hopefully useful to those of you thinking about ways to break up your monolithic Rails application.
September 04, 2014
New Features in Rails 4.2
I have highlighted few features of Rails 4.2 in a blog post. Have a look.
I just published a blog post on dealing with my inferiority complex

Would love to get some feedback!
In case you didn't know, you can use your MongoDB document _id field for date range queries instead of having to use a separate created_at field and create a separate index for it. Here's how simple it is to do it.
After we wrote the tutorial series to set up Bootstrap and Rails, we got a few requests to write a series for setting up Zurb Foundation on a Rails app. And... here they are!

Integrating Rails and Foundation - part 1, the installation
Integrating Rails and Foundation - part 2, the CSS and Components
Integrating Rails and Foundation - part 3, Javascript Based Components
I've been trying to incorporate refactoring into our code reviews. The idea is to use refactoring as a way to understand code while reviewing it. I picked up this idea from the book "Refactoring" by Martin Fowler. Here's a blog post of my experience with this technique.
When we first start with Rails we learn to create one controller for each resource, but separating your contexts into multiple controllers can help a lot with making your application easier to understand, maintain and grow.
September 03, 2014
Like the X-Men nightcrawler this rubygem teleports your assets to a OpenStack Swift bucket/container. It was designed to sync your assets with OpenStack Swift and allow some operations with your buckets/containers.
This article discusses a new feature in RSpec 3 called verifying doubles. Verifying doubles ensure that doubles stay in sync with actual code. The article explains how to start using this feature and includes some general thoughts about how this feature will impact testing practice.
We just posted new article on our blog - it is really usefull when you translate languages with many plural forms.
My First Ruby Gem
I came across this excellent walkthrough about creating a rubygem and thought that it would be helpful to others.
I just posted an article Seamlessly Navigate Rails Projects With Tmux. I hope you find it useful!
A good read demonstrating how using service objects decouples concerns, simplifies testing and helps produce clean, maintainable code: Service objects in Rails will help you design clean and maintainable code. Here's how..
Each acceptance test tells a story: a logical progression through a task within an application. As developers, it’s our responsibility to tell each story in a concise manner and to keep the reader engaged, aware of what is happening, and understanding of the purpose of the story.

At the heart of understanding the story being told is a consistent, single level of abstraction; that is, each piece of behavior is roughly similar in terms of functionality extracted and its overall purpose.
September 02, 2014
Exceptions should be exceptional, they should be unexpected. But how unexpected can an error be if you see it thirty times a day?

Most noisy exceptions fall into a few basic categories. And for each of these categories, you can use some patterns to cut down the noise and make your users happier at the same time.
The Serialization Duck Type
We're going to take a look at common Duck Types in Ruby.

First off, let's take a look at the Serialization Duck Type and see how it provides a simple informal interface for converting objects to and from strings.
How to get raw sound track from SoundCloud with Ruby?
I blogged about the value of the docs badge provided by Inch CI and what project maintainers can get out of it.

Read more
After migrating several projects from Cancan to Pundit i've wrote a simple DSL for make writing Pundit's rules easier pundit_dsl
Role-Based Authorization in Rails
I’ve written an article on Rails authorization, showing how to implement simple role-based authorization, and comparing the Pundit and CanCan gems, with links to the rails-devise-roles example application, which you can generate with Rails Composer.
September 01, 2014
For my personal purpose i needed to map complex and unstructured csv files, i've wrote a gems csv2hash for help me to do that, is a parser based rules, i hope this gems can be useful for another persons.
In this post, I show you how to build alternative many-to-many relationships without creating join tables.

I just wrote an introduction about how the new gems active job and global id interact in rails 4.2
August 31, 2014
FastAttributes is a gem which defines attributes with their types in your model and does it in the fastest way. Version 0.7.0 is just released and since now, it supports lenient data types.
Green Ruby News #82
Finished my weekly links harvesting, check the result on Green Ruby News #82.
Make the most of SQS using Ruby
While not particularly famous in the Ruby community, SQS is a really amazing queueing service, check out what it can do for you and how little Ruby code you have to write to use it.
August 30, 2014
DescriptiveStatistics is a gem that adds methods to the Enumerable module to allow easy calculation of basic descriptive statistics of Numeric sample data in collections that have included Enumerable such as Array, Hash, Set, and Range. The statistics that can be calculated include Number, Sum, Mean, Median, Mode, Variance, Standard Deviation, Percentile, Percentile Rank, Descriptive Statistics, and Quartiles.

When requiring DescriptiveStatistics, the Enumerable module is monkey patched so that the statistical methods are available on any instance of a class that has included Enumerable. For example with an Array:

> require 'descriptive_statistics'
=> true
> data = [2,6,9,3,5,1,8,3,6,9,2]
=> [2, 6, 9, 3, 5, 1, 8, 3, 6, 9, 2]
> data.number
=> 11.0
> data.sum
=> 54.0
> data.mean
=> 4.909090909090909
> data.median
=> 5.0
> data.variance
=> 7.7190082644628095
> data.standard_deviation
=> 2.778310325442932
> data.percentile(30)
=> 3.0
> data.percentile(70)
=> 6.0
> data.percentile_rank(8)
=> 81.81818181818183
> data.mode
=> 2
> data.range
=> 8
August 29, 2014
Creating a simple ToDo with Rails
Creating a simple ToDo application With Rails.
Amazon provides Simple Queue Service also knows as SQS. It is a fast, reliable, scalable, fully managed message queuing service in the cloud that you can use from your applications. This is how you can use it from Sinatra/Ruby.
Imagine developing an application where you need to grab shipping data in real time, send products, inventory, and order information over at least ten different APIs including Amazon and eBay. When I first heard that I had to do this, there could only be one answer: “Challenge accepted”. Continue reading.
August 28, 2014
Made a thing that makes setting up configurable gem variables with optional defaults super easy. Implementation details here -
Reading Rails - TimeWithZone
Timezones are not fun.

Thankfully, Rails largely deals with them behind the scenes.
Learn how TimeWithZone works, and when you run into that crazy timezone bug, you'll know where to start looking.
Paperdragon is a new alternative to Paperclip and CarrierWave. Its very explicit API uses Dragonfly under the hood and gives you control about every aspect for processing uploaded images.