Nick Sieger: Fresh 0.9.2 activerecord-jdbc-adapter Release tag:blog.nicksieger.com,2005:Typo Typo 2010-11-22T19:02:37+00:00 Nick Sieger urn:uuid:90dd449a-c030-4700-b7b7-37cfffaa54f1 2009-10-19T14:01:16+00:00 2010-11-22T19:02:37+00:00 Comment on Fresh 0.9.2 activerecord-jdbc-adapter Release by Nick Sieger <p>Sigi: Your case is a bit unusual, and one that I hadn&#8217;t anticipated in this latest release&#46;</p> <p>The problem is that the only way I could work around Rails&#8217; requirement to load &#8216;pg&#8217; when the PostgreSQL adapter is loaded is to include an empty, placeholder <code>pg.rb</code> in activerecord&#45;jdbc&#45;adapter&#46; If you simply remove that file (<code>lib/pg.rb</code>) in the installed ar&#45;jdbc gem, you should be ok&#46;</p> <p>Sadly, I&#8217;m not sure if I can prevent this problem without changes to Rails, unless perhaps I can find a way to load the real <code>pg</code> (if it is installed) from within my stub pg&#46;rb&#46; Thoughts?</p> Sigi urn:uuid:918ae1cb-811d-4617-b35f-55073990f64e 2009-10-18T23:24:25+00:00 2010-11-22T19:02:37+00:00 Comment on Fresh 0.9.2 activerecord-jdbc-adapter Release by Sigi <p>Sorry for the back&#45;to&#45;back posting, but I&#8217;d also like to mention that even without my somewhat exotic requirement it can be very irritating to suddenly have your app not working anymore under MRI, only because you installed a Java only adapter into the wrong GEM_HOME by accident ;&#45;)&#46;</p> <p>So if there&#8217;s an easy way to avoid this problem it should be considered&#46;</p> Sigi urn:uuid:363df9ae-5b89-47eb-8c2c-eb14b461ebc4 2009-10-18T23:15:31+00:00 2010-11-22T19:02:37+00:00 Comment on Fresh 0.9.2 activerecord-jdbc-adapter Release by Sigi <p>This is a good patch, but something seems to be missing still&#46; Here&#8217;s what I&#8217;m facing:</p> <p>I want to actually have both my native DB gem (&#8216;postgres&#8217; in my case) AND the Java stuff installed in the MRI gem tree&#46;</p> <p>Although I won&#8217;t be able to use the JDBC adapter from MRI (and the patch will ensure it&#8217;s not loaded anyway), this gives me the possibility to run &#8216;warble&#8217; from MRI&#46; In other words, I want to package the Java app without having to use &#8216;jruby&#8217; (or somehow juggling GEM_HOMEs)&#46;</p> <p>Now here&#8217;s the actual problem: if I have both &#8216;pg&#8217; as well as &#8216;activerecord&#45;jdbc&#45;adapter&#8217; installed (in my MRI GEM_HOME), Rails seems to load the wrong adapter&#46; When running the app in MRI, on first DB access I get &#8220;uninitialized constant ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::PGconn&#8221;&#46;</p> <p>Uninstalling &#8216;activerecord&#45;jdbc&#45;adapter&#8217; restores a working condition&#46; So it seems I cannot install it along with &#8216;pg&#8217;&#46;</p> <p>This happens regardless of having the jdbc generator ran or not&#46;</p> <p>Any advice? I&#8217;d really like to be able to WAR package AND develop with MRI, and keeping all the necessary gems installed in parallel&#46;</p> Nick Sieger urn:uuid:e0e8bb85-3cd7-43f9-a30c-33b51527f2cd 2009-10-16T16:00:10+00:00 2010-11-22T19:02:37+00:00 Comment on Fresh 0.9.2 activerecord-jdbc-adapter Release by Nick Sieger <p>Vivek: jdbcmysql and sqlite3 adapters are released too&#46; But know that you don&#8217;t need them anymore; you can install just the base jdbc adapter + jdbc&#45;mysql or jdbc&#45;sqlite3 and that will work too&#46;</p> vivek.pandey@gmail.com urn:uuid:83a44270-5fad-4864-bbda-dc203ca4ab8c 2009-10-15T20:43:12+00:00 2010-11-22T19:02:37+00:00 Comment on Fresh 0.9.2 activerecord-jdbc-adapter Release by vivek.pandey@gmail.com <p>This is great! No more editing database&#46;yml required&#46; Going to help great deal in keeping the application portable between MRI&#46; Would you follow up with releasing activerecord&#45;jdbcmysql&#45;adapter or activerecord&#45;jdbcsqlite3&#45;adapter with 0&#46;9&#46;2 dependency?</p> Vladimir Sizikov urn:uuid:00a3454c-947a-4e0c-bf74-299e303e116d 2009-10-15T13:30:15+00:00 2010-11-22T19:02:37+00:00 Comment on Fresh 0.9.2 activerecord-jdbc-adapter Release by Vladimir Sizikov <p>Cool, now I have a link to point to every time I&#8217;m asked why db:create didn&#8217;t create the tables anymore&#46;&#46;&#46; :)</p> jonbaer urn:uuid:e35e0fb5-704b-4e88-9f67-2174c5a4b3a2 2009-10-15T09:07:38+00:00 2010-11-22T19:02:37+00:00 Comment on Fresh 0.9.2 activerecord-jdbc-adapter Release by jonbaer <p>Awesome fix, +1 for this, much needed for switching between MRI (dev) and JRuby (deploy)</p> acid urn:uuid:82401770-5f0b-467f-ac29-be3135e86ccb 2009-10-14T12:58:14+00:00 2010-11-22T19:02:37+00:00 Comment on Fresh 0.9.2 activerecord-jdbc-adapter Release by acid <p>Sweet, thanx! :D</p> bryanl urn:uuid:e48df09f-5572-443e-bae0-702a6ffd05fd 2009-10-13T16:31:02+00:00 2010-11-22T19:02:37+00:00 Comment on Fresh 0.9.2 activerecord-jdbc-adapter Release by bryanl <p>sweet&#46; this is a good change&#46;</p> Nick Sieger urn:uuid:65e528d4-1673-400f-b67c-60f97a152db4 2009-10-12T18:30:45+00:00 2010-11-22T18:18:11+00:00 Fresh 0.9.2 activerecord-jdbc-adapter Release <p>As <a href="http://markmail.org/message/mkwdu56wp74pj4tf">announced last week on the jruby&#45;user list</a>, 0&#46;9&#46;2, the latest <code>activerecord-jdbc-adapter</code> release, has been pushed out&#46; Please install the gem in the usual fashion and try it out on your applications&#46;</p> <p>One of the <a href="http://jira.codehaus.org/browse/JRUBY-3502">most contentious bugs</a> broke <code>db:create</code> and <code>db:drop</code>, ruining the quick&#45;start workflow that Rails is known for&#46; To fix this, a creative solution was needed that ended up bringing some nice benefits&#46;</p> <p>The problem stemmed from the fact that some database setup tasks in Rails 2&#46;3 no longer load the environment; instead they just load the configuration data and work with that&#46; This means that there is no easy way to hook into Rails and override those tasks, which is <a href="http://github.com/nicksieger/activerecord-jdbc-adapter/blob/master/lib/jdbc_adapter/jdbc.rake">what activerecord&#45;jdbc needs to do</a>&#46;</p> <p>The solution I ended up with was to create a <code>jdbc</code> Rails generator that inserts a couple files into your rails application that inject the JDBC logic into ActiveRecord and the database rake tasks&#46; To wit:</p> <pre><code>$ jruby script/generate jdbc exists config/initializers create config/initializers/jdbc.rb exists lib/tasks create lib/tasks/jdbc.rake </code></pre> <p>The upside of this new technique is that now that we have a way to ensure the JDBC adapter is properly injected into Rails, and you no longer need to use adapter names like <code>jdbcmysql</code>, <code>jdbcsqlite3</code> and the like&#46; The net result is that <strong>database&#46;yml no longer needs to be modified</strong> for the default Rails databases (<code>mysql</code>, <code>sqlite3</code>, <code>postgresql</code>)&#46; So while we introduced one additional step in the process to bootstrap a Rails application under JRuby, the removal the step where <code>database.yml</code> needs to be modified results in a more predictable workflow&#46;</p> <p>The new JRuby&#45;specific Rails workflow looks like the following, assuming you&#8217;ve installed the <code>activerecord-jdbc-adapter</code> gem into JRuby, along with the appropriate database driver gem (e&#46;g, <code>jdbc-mysql</code>)&#46; (Of course, the gems only need to be installed once per JRuby installation&#46;)</p> <ol> <li>Create your Rails application as usual&#46;</li> <li>Run the <code>jdbc</code> generator as shown above&#46;</li> <li>Profit!</li> </ol> <p>Additionally, if you maintain a <a href="http://m.onkey.org/2008/12/4/rails-templates">Rails application template</a> that you use to start a new application, you can simply add <code>generate(:jdbc)</code> to that template&#8217;s script&#46;</p> <p>What&#8217;s more, the presence of the JDBC files in your application are guarded and only inject JDBC support when running under JRuby, so you can safely keep them around when running Rails under multiple Ruby implementations&#46;</p> <p>For more details of what&#8217;s in the release please consult the <a href="http://rubyforge.org/forum/forum.php?forum_id=34972">mini&#45;changelog on Rubyforge</a> and the <a href="http://kenai.com/jira/browse/ACTIVERECORD_JDBC/fixforversion/10195">list of fixed issues in JIRA</a>&#46;</p>