November 2011
1 post
Model default values
When looking for the best way to make default values, I’ve found that you shouldn’t rely on the DB for these. So in order to integrate these on your Model, I usually follow the next best practive:
class User after_initialize :init def init self.number ||= 0.0 end end
This way it will initialize to 0.0 if the value is nil
October 2011
3 posts
Custom Validation (twitter bootstrap checkbox)....
After creating the custom input on Part 1, we now needed to include a custom getter for each of these inputs. We could set up a method for each input inside our model but that wouldn’t be as cool, so we create a gem with the following behavior:
Object.instance_eval do
def check_for_check( *attrs )
attrs.each do | attr |
self.class_eval %Q{
def...
Custom Input with Twitter Bootstrap
Using simple_form and Twitter’s bootstrap we can implement a custom input for the prepend left box used in bootstrap.
First you create an inputs folder under your app directory and then a file named left_box_input.rb with the following code:
class LeftBoxInput < SimpleForm::Inputs::Base def input "<div class='input-prepend'><span...
Custom Validation (twitter bootstrap checkbox)
After jumping the wagon with Twitter Bootstrap for a new client app we are working on, I found myself in to some problem trying to implement this type of input:
We only have one input let’s say name and we wan’t to validate it’s presence when the check is true. The check is a virtual attribute named name_check. So using simple_form gem for this form.
We need to create the...
August 2011
3 posts
Rails 3.1 custom serialize
A new feature that really makes our lives easier is the custom serialize option. Let’s say that your DB requires that when you save a serializable attribute to be in a CSV form instead of the YAML default.
If this is the case then you could use the following
class CommaSeparatedList
def load(text)
return unless text
text.split(",")
end
def dump(text)
...
Rails 3.1 asset pipeline
When you’re trying out the new asset pipeline it might will be hard to debug any CSS/JS since it will all be compressed in to one file.
When you use the link/include tag remember to add the next parameter
stylesheet_link_tag :admin, :debug => Rails.env.development?
javascript_include_tag :admin, :debug => Rails.env.development?
This way it will only server the files separately...
Installing Rails 3.1 --pre on OSX Lion
After trying several ways of doing
gem install rails --pre
and still getting errors, I found the following to do the trick
rvm gemset rails --pre
It will save you a couple of hours.
April 2011
1 post
Paperclip Scopes
A nifty pair of scopes for when you’re working with attachments on Paperclip that are images or other type of content.
# For finding images as in Article.attachments.images scope :images, where("file_content_type LIKE ?", "image%") # For finding other files Article.attachments.docs scope :docs, where("file_content_type NOT LIKE ?", "image%")
January 2011
1 post
New Stickers
We are getting new stickers for our friends and clients who want to put them in the laptops/cars/bathroom stalls.
Here is a preview, get them while they’re hot.
November 2010
1 post
My favorite Spec of the day
Here is the controller spec!
def notify
@user = User.find(params[:id])
if @user.is_expert?
@topic.experts << @user
end @
user.notify_about_topic!(@topic)
end
And the implementation
it 'should notify user and add to leader board if user is an expert' do
user = mock_model(User, :is_expert? => true)
topic = mock_model(Topic, :id => 1)
collection =...
October 2010
1 post
August 2010
1 post
Mass Payment - Paypal
When trying to figure out how to send multiple payments to different Paypal users, I stumbled into the Mass Payment feature.
This feature allows to send multiple payments in one call but more importantly is that the only charge %2 of the payment cap at $1 USD. Also you can send the payments in multiple currencies.
After digging around the web there wasn’t any post about how to make use of...
June 2010
1 post
Rails 3 + Metal
There has been a lot of talk about the new changes being introduced into rails 3, trying to upgrade current applications I found out a recipe for upgrading your Metal code:
The first thing is to change
require(File.dirname(__FILE__) + ”/../../config/environment”) unless defined?(Rails)
into
require File.expand_path(’../../../config/environment’, __FILE__) unless...
April 2010
1 post
La Vitrine
Moment Factory developed the interactive system and designed the interactive content.
The installation includes tracking devices and low-resolution LED displays and is capable of showing many different visualizations based on the presence and movement of people.
Visitors can interact with the installation every night from 7 PM to 11 PM. La Vitrine 145, rue Sainte-Catherine Ouest, Montréal.
March 2010
1 post
go: flag →
Checking out the flag package, Go’s built in command line argument parser. Here’s a simple example:
// flag.go
package main import ( "flag" "fmt"
) var code *int = flag.Int("areacode", 716, "give me your codes") func main() { fmt.Printf("Testing out flags!\n"); flag.Parse();...
December 2009
2 posts
Rails Tutorial →
For all new comers to RAILS please do check it out.
Si eres nuevo en RAILS, este tutorial es el mejor.
Tokio Cabinet
Tokyo Cabinet resources
http://1978th.net/tokyocabinet/index.html
official page and presentation (really dense)
http://1978th.net/tokyocabinet/rubydoc/
cabinet rdoc
http://openwferu.rubyforge.org/tokyo.html
install instructions, best way to learn is to play in the mud
http://www.igvita.com/2009/02/13/tokyo-cabinet-beyond-key-value-store/
relly good overview and performance analys of ruby...
November 2009
2 posts
Video de mi presentación para el sitio Pio.la sobre Mongo Mapper
September 2009
1 post
August 2009
2 posts
New design
Welcome to our newly redesigned webpage, we feel that this new look suits us good. As we strive to become better we think that our customer relationship should evolve just as our technologies. That is why we’re launching some new exciting for future and current customers.
Project status and percentage of completion. Clients will be able to check online for stories completed via Pivotal Tracker...