about 1 year ago - 4 comments
Recently I switched to Postgres for my Rails database needs. Everything is good, but when running tests I get pages of NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index … spewing into my output. I asked around and got some help from @robtreat2. A quick search lead me to the Postgres docs on…
about 1 year ago - No comments
I remember reading about has_many_polymorphs a couple of years ago, then again last year. Each time around when I wanted some sort of polymorphic has_many :through. Each time I figured, “Eh, it’s just another couple of tables” or “I can just map them in a method in the model, there’s not that much data”. But…
about 1 year ago - No comments
Just wanted to share a quick tip about an error I ran into. When running a Rails migration and changing a column that doesn’t exist, you’ll get an undefined method `type=’ for nil:NilClass error. The cause for me was that I had used change_column on login, which my table didn’t have instead of email, which…
about 1 year ago - No comments
While working on Pixie we wanted to be able to import any image from the web into the editor. Ideally this would all occur in client-side JavaScript, but due to a “security” restriction* I believe that it is not possible without extensive workarounds. Fortunately loading an image on the server is actually much easier than…
about 2 years ago - 2 comments
Because it took me way, way too long to find this out. ./script/plugin install git://github.com/technoweenie/acts_as_versioned.git That is all. Don’t gem install, don’t config.gem, don’t believe the out of date documentation and its lies.
about 2 years ago - 1 comment
You know those adjectives that come after nouns? Well, sometimes you may want to pluralize them correctly in your Rails App. I might have been able to get by with “work_in_processes”, but “bill_of_materialsses” just wasn’t going to cut it. Here’s the technique I used: # Add new inflection rules using the following format: ActiveSupport::Inflector.inflections do…
about 2 years ago - 3 comments
So check it, the long term vision: JavaScript RubyVM (HotRuby) provides a way to script in Ruby on legacy browsers (IE). Ruby implemented natively as a clientside scripting language in all modern browsers (Chrome, Firefox). jQuery continues to rock the DOM. Everyone wins!
about 2 years ago - 38 comments
If you’re using a model or controller from an engine in Rails 2.3.2 you may encounter some crazy errors from time to time. Errors like: A copy of ApplicationController has been removed from the module tree but is still active! Or sometimes the even weirder one: can’t dup NilClass In one situation where you get…
about 2 years ago - No comments
This is something that I’ve often needed to do: add a new column to the DB that has a non-null constraint, but also doesn’t have a default value. There are a some options: Forget the DB constraint and use `validates_presence_of` in the model Add a default value for the new column with non-null and then…
about 2 years ago - No comments
So, better late than never I guess… I’ve been Ruby Quizmaster for about two months now. The Ruby Quiz site is at http://rubyquiz.strd6.com. This is the third incarnation of Ruby Quiz, a weekly quiz that let’s you put your Ruby skills to the test. The first quiz was started by James Edward Grey II, there…