Category Archive: ruby

Jan
14

Reloading models in Rails 3.1 when usign Spork and cache_classes = true

Speeding up you tests with Spork is very common when developping Rails applications. What Spork do is preloading your application in a server and copies a fork of that server whenever you run tests. It avoids reloading all the rails stack !! That is great !!! But the problem I ran into is that I …

Continue reading »

Sep
27

Rubygems mini mirror

Hey all, I just have published a new gem called rubygems-mini_mirror. This is a small stuff that needs improvement on speed speaking but it works. I will explain later on how it works because I have no time for that now. Bookmark on Delicious Digg this post Recommend on Facebook share via Reddit Share with …

Continue reading »

Mar
17

Rspec 2.x and Fixtures

Hello, It’s been a while when I last updated this blog. It seems that Rspec 2 can not use fixtures from Activerecord 2.3.x ! Impossible ? Not really, and thanks to ruby it was possible for me. Let’s describe the background : First of all, I had a gem built on jeweler that uses ActiveSupport::TestCase …

Continue reading »

Jan
12

HTTPClient and SSL verify certificate

If you as us in my company use self signed certificate and ran into an OpenSSL::SSL::SSLError when using httpclient gem. Here is how to bypass ssl certificate verification : The issue : require ‘rubygems’ require ‘httpclient’   client = HTTPClient.new url = "https://www.server1.com" client.get(url) at depth 1 – 19: self signed certificate in certificate chain …

Continue reading »

Nov
17

ActiveRecord like searching object in Rails form helpers

Ruby is a wonderful language. And Rails is a wonderful framework. Why ? Because of Duck typing !!! Example : You build a database application for a book store Books are classified by : Genre Author Country On a search page, you can search with a title text field, author select box, genre checkboxes. So …

Continue reading »

Oct
20

Ruby Rails : How to bypass skip validation in Devise

Since my last post with email validations, I was looking for a solution to integrate it with devise Sadly for me, devise implements the old way of validating email with regexp : # From devise gem version 1.1.3 validates_format_of :email, :with => email_regexp, :allow_blank => true Well, as I don’t want to hack activemodel’s code, …

Continue reading »

Aug
19

Enumerable grep method in Ruby

There is some methods that are not very known among ruby developpers. One of them is Enumerable#grep method. I would like to share one of the use case I have to face with, and how I implement grep. Purpose, I have a Hash representing a simple network I’d like to select all the people related …

Continue reading »

Jul
21

Email validation in Ruby On Rails 3 or Active model without regexp

In Rails 3.0, you can use custom validator in your active_record model. So I wanted to manage email validations without regexp matching like others do. I find a new way to make this work thanks to ruby mail gem, a dependency of Rails 3.0 I use this with devise, see my blogpost here : Ruby …

Continue reading »

Jul
07

How to translate your column fields and values with gettext in ruby on rails

I am proud to have published my first useful ruby gem. It is called gettext_column_mapping, you can check out the code in my github repository. I already released it as a gem through gemcutter/rubygems It is based upon Masao Mutoh (gettext and gettext_active_record) and Michael Grosser (fast_gettext and gettext_i18n_rails) works. Thanks to them History In …

Continue reading »

Jun
29

Bundler default Gemfile and custom Gemfile, example of wirble

Hi all, A simple trick I want to share with you if you are using Bundler (or rails 3) It matters if you want to install wirble gem in your workstation but not in your server Sometimes, you want to include some gem that are not mandatory for your application to run but you want …

Continue reading »

Older posts «