I literally always have to look up the meaning of :limit in migrations when it comes to integer values. Here’s an overview. Now let’s memorise it (oh, this works for MySQL, other databases may work differently):
Posts Tagged ‘Rails’
Once and for all: Rails migrations integer :limit option
August 20th, 2009Speaking at Rails Underground
June 14th, 2009
I haven’t seen a schedule yet, but I’ve been told by Mark that I’ll be speaking at Rails Underground this year.
My talk will be on the topic of Git. In about 45 minutes time I’ll show you all the basic git features you’ll need on a daily basis. Not only that, but I’ll also explain how git manages all those commits and branches so you can be on your way to become a git power user.
has_one – find all that have no associated object
June 7th, 2009Let me pose a typical Rails situation:
class Person < ActiveRecord::Base has_one :fancy_hat end class FancyHat < ActiveRecord::Base belongs_to :person end
Now, how can you get all the people that don’t have a fancy hat?
class Person < ActiveRecord::Base has_one :fancy_hat named_scope :hatless, :joins => 'LEFT JOIN fancy_hats ON fancy_hats.person_id = people.id', :conditions => 'fancy_hats.person_id IS NULL' end
Now you can find all the hatless people you want.
FYI: Finding fancy hats that have no one to wear them is a lot easier, because the foreign key is stored in the fancy_hats table.
How To Start A Rails Edge App The Easy Way
January 4th, 2009There’s a lot of cool stuff pooring in about what’s new in Rails Edge (which will become Rails 2.3 and/or Rails 3).
Most likely you can’t wait to get started with these new features, especially when you’re about to start a new project, which doesn’t have to be stable yet, but will be by the time 2.3/3.0 come out. This post shows you the way to create a new Rails app based on the most current Rails code, also called Edge Rails.
RSpec’ing with Time.now
November 5th, 2008I’m currently writing some RSpec tests that use Time.now.
I want my model to calculate a duration and store the future time in the database. I’ve already specced the calculation of the duration, but I also want to spec that everything gets saved correctly. Here’s my first spec:
it "should do stuff" do m = Model.create() m.expires_at.should eql(Time.now + some_value) end
This fails.
BaseApp: a quick start for your Rails App
September 28th, 2008BaseApp is no longer maintained. There is a very good alternative called bort.
For the impatient: http://github.com/ariejan/baseapp
Got issues? Feature requests or patches? http://baseapp.lighthouseapp.com/
Every Rails developer has at least once developed an application that needed user authentication and some basic UI features like tabs and a sidebar. Ask yourself now: “how often have you installed and extended the restful_authentication plugin?”.
Skinny Controllers and Overweight Models
August 17th, 2008All Rails developers know the slogan “Skinny Controllers, Fat Models” and I heartily agree with it. Every conference you go to, you hear it. But there’s a problem! My Fat models got overweight!
ActiveRecord Read Only Model
August 17th, 2008ActiveRecord is great in providing CRUD for your data models. In some cases, however, it’s necessary to prevent write access to these models. The data may be provided by an external source and should only be used as a reference in your application, for example.
Zoek jij ‘n uitdagende baan??
June 6th, 2008First off, sorry to all the English-reading people, but this post is intended for my Dutch audience.
Even wat updates voor mijn Nederlandstalige publiek. Ik heb wat nieuwtjes voor jullie, dus lees snel verder!
Debian Etch: RMagick LoadError
April 10th, 2008If you’re on Debian Etch, you may encounter the following error
libMagickWand.so.1: cannot open shared object file: No such file or directory - /usr/lib/ruby/gems/1.8/gems/rmagick-2.3.0/lib/RMagick2.so
This basically means that the libMagickWand.so.1 file cannot be found. However, it is available on your system. All you need to do to fix it, is tell your box to look in the right place for the file.
