How to make Rails ActiveRecord::Migration default to MyISAM

Some people perfer InnoDB, other MyISAM. This post ain't about a MySQL-Engine flame war but about letting people choice. Fact is, the excellent Migration system shipped with [rubyonrails](http://rubyonrails.org/) and ActiveRecord is defaulting to InnoDB. The [doc](http://ar.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#M000125) shows how you can specify the engine on each create_table statement. but then your migration are mysql-only because these engine options will not be supported by sqlite or MSSQL. and I dont want to copy/paste these options to all of my create table. I want to change the default. unfortunately Rails supply no options for it fortunately Rails is built on Ruby. so you can simply overwrite the proper method by adding it to your config/environment.rb
module ActiveRecord
        module ConnectionAdapters
                class MysqlAdapter < AbstractAdapter
                        def create_table(table_name, options = {}) #:nodoc:
                                super(table_name, options.reverse_merge(:options => "ENGINE=MyISAM"))
                        end
                end
        end
end

Tags , , , , , , , , ,

Posted in , , | Posted on 08 Apr 2009 13:56by somekool |

2 years and a half of ruby on rails

It has been 2 years and a half already since I had the pleasure to met [David H. Hansson](http://www.loudthinking.com/) also known as DHH. He convinced me to use ruby on rails and swear by it from now on in the first week of November 2004. He was well prepared but it was easy anyway.... with such a nice technology, I can recognize what is good and I loved it right away. What he thought could be a week of arguments about our favorite technology took him only a few hours and then we could concentrate on our work and he helped us a lot. I am happy I met him while he was not so famous, or at least I did not know him at all. He was just some guy coming which who we are spending a week training. If I had knew him, the whole week would have been so different. Admiring someone leads to much less productivity than just listening to someone. I remember even, before we take the picture before he leaves I remember thinking not being sure why we needed a picture. Now I am very happy to have [this picture](http://www.flickr.com/photos/84855241@N00/8756806/). ![picture](/files/8756806_a9795805cc.jpg) I was working at [Combustion Labs](http://www.combustionlabs.com/) in [Vancouver](http://www.vancouver.com/) and [our great boss](http://www.google.com/search?hl=en&client=safari&rls=en&q=michael+stephenson+ubertor&btnG=Search) met DHH in a Chicago conference and decided to hire him to train us for a week. Thank you Mike. And Thank you David H.H., because of you I now have a tool to suggest to help people write clean code and I of course have the best web development platform. Big Thanks

Tags , , , , , , , , , , ,

Posted in , | Posted on 10 Jun 2007 22:55by somekool |

Tracking down not found rhtml templates in rubyonrails applications

Maybe you've seen this error before?
No rhtml, rxml, rjs or delegate template found for [view_name] (ActionView::ActionViewError)
I have a slightly special setup for my error mailer in [one of my rubyonrails applications](http://justbudget.com), as the mailer is not in app/models and the view not in app/views. This used to work fine, until I changed god knows what and I realized it was broken for a little while. (by now, I, of course, know what broke it). And it was pretty hard to debug because I am using the system-wide installed rubyonrails on a shared hosting on which I don't have root access. So at first I wanted to put some more logging in there to help me debug this beast. but for some reason, running the application with my own rails in vendor/rails was breaking everything. Can't edit the files, can't run my own, hmm.... what to do? So today I took the few minutes it was requiring to find the right little place to put the proper logging. One thing I should add, I am an excessively lazy programmer and I like things to be short and sweet. So I did not want to copy paste a 10-15 lines function into my code. but there it is I found this one. **template_exists?** is only 3 lines of code, so no big deal to copy paste. there is not much chances it will change so much in the future versions of rubyonrails.
module ActionView
        class Base
                def template_exists?(template_path, extension)
                file_path = full_template_path(template_path, extension)
                logger.error(file_path)
                @@method_names.has_key?(file_path) || FileTest.exists?(file_path)
        end
        end
end

Just place this little piece of code at the end of application.rb for example and every templates that are tried will be logged in your development.log or production.log file. It helps very much to track path problems as the regular error message isn't really descriptive. that's it, enjoy.

Tags , , , , , , , , ,

Posted in , , | Posted on 12 Nov 2006 04:37by somekool |

Gotta Love Dreamhost

So Dreamhost recently celebrated their 9th anniversary. and for this event they upped our disk space and bandwidth limit BY TEN (10). Actually, it feels like 20x. So I was using 30% of my 20GB of space (got lot of pictures). and suddenly I am now only using 3% for my new 200GB of space ;) I wonder what would happen if everyone would suddenly decide to fill it up ;) ![Dreamhost Host Quota, gotta love 'em](/files/dreamhost_quota.png) The best part is, I got this account for so cheap, I'm even a bit shy to tell you all the details.... So go ahead and create yourself a Dreamhost account by clicking [here](http://www.dreamhost.com/r.cgi?116075) and save even more money by using this coupon code. **GODREAMHOST20** Simply enter the coupon when you sign up for your account, you will save 20$ dollars on your invoice. its as easy as that. if you need more info about Dreamhost and what not, feel free to ask me. I used them for a bit more than a year now. And I am simply more satisfied with them every single month.

Tags , , , , , , , , , , , , , , , , , , , , ,

Posted in , , | Posted on 03 Oct 2006 19:57by somekool |

Couple of Rails links

Here is a couple of links about rubyonrails performance and m2m features I ran into today. I just want to keep them as I do not have time to go through them all fully and assimilate everthing. ## about performance * [railsexpress's rails template optimizer beta test](http://railsexpress.de/blog/articles/2006/08/15/rails-template-optimizer-beta-test) * [infoq's Rails Performance](http://www.infoq.com/articles/Rails-Performance) * [scada2's ruby on rails is it really simple](http://scada2.blogspot.com/2006/08/ruby-on-rails-is-it-really-simple.html) * [serverside project page](http://code.google.com/p/serverside/) * [serverside rdoc](http://serverside.rubyforge.org/) * [railsbench](http://railsbench.rubyforge.org/) ## about has_many :through * [Collection assignment to a has_many :through](http://www.ruby-forum.com/topic/76825) * [join models not proxy collections](http://blog.hasmanythrough.com/articles/2006/04/17/join-models-not-proxy-collections) ## My favorite tooltip js library * [walterzorn's js tooltip](http://www.walterzorn.com/tooltip/tooltip_e.htm)

Tags , , , , , , ,

Posted in , , , | Posted on 05 Sep 2006 22:28by somekool |

Subscribe

my last twitter posts

Personal Links

Tags

Categories

Archives

my Xbox 360 gamertag

Copyright © Mathieu Jobin's Life and Thoughts