<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description>father, husband, software engineer, emacs devotee, wannabe snowboarder
Emacs Blog</description><title>Neutron Flux</title><generator>Tumblr (3.0; @nflux)</generator><link>http://neutronflux.net/</link><item><title>Eye Street: :accepts_nested_attributes_for with Polymorphic Associations and a Custom Autosave</title><description>&lt;a href="http://blog.research.eyestreet.com/post/7309604903"&gt;Eye Street: :accepts_nested_attributes_for with Polymorphic Associations and a Custom Autosave&lt;/a&gt;: &lt;p&gt;&lt;a href="http://blog.research.eyestreet.com/post/7309604903" class="tumblr_blog"&gt;A recent post that I wrote for work&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Wheew… what a title… kinda dry, very geeky, but if you landed here, hopefully this will help. This blog documents some of the code wrangling that we did for a recent app, &lt;a href="http://vrcompliance.com"&gt;VRCompliance&lt;/a&gt;. I needed to have the ability to create multiple phone numbers when inputting either addresses or people in our…&lt;/p&gt;&lt;/blockquote&gt;</description><link>http://neutronflux.net/post/7341736056</link><guid>http://neutronflux.net/post/7341736056</guid><pubDate>Thu, 07 Jul 2011 08:11:24 -0600</pubDate></item><item><title>Emacs Configuration</title><description>&lt;p&gt;I&amp;#8217;ve had my emacs configuration under version control for the better part of the last decade, cvs then svn, and for the last 3 years git. I finally bit the bullet, and purged it of private data. Since I doubt the history is that interesting to most people, I kept a local historical branch, and then truncated the master branch which is now available in my  &lt;a href="https://github.com/rwc9u/dotfiles"&gt;github repos&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I used to use a monolithic .emacs file. When I &lt;a href="http://emacsblog.org/2007/10/07/declaring-emacs-bankruptcy/"&gt;declared .emacs bankruptcy&lt;/a&gt; a few years ago, I followed &lt;a href="https://github.com/rmm5t/dotfiles"&gt;@rmm5t&amp;#8217;s&lt;/a&gt; and &lt;a href="https://github.com/defunkt/emacs"&gt;@defunkt&amp;#8217;s&lt;/a&gt; conventions&amp;#8230; albeit probably not as nicely.&lt;/p&gt;</description><link>http://neutronflux.net/post/4770184229</link><guid>http://neutronflux.net/post/4770184229</guid><pubDate>Tue, 19 Apr 2011 23:55:00 -0600</pubDate></item><item><title>Forcing :before_validations to run and save the updated data</title><description>&lt;p&gt;I meant to write this up awhile ago, but just want to get it out&amp;#8230; Have you ever decided to massage incoming data in a :before_validation. I ran into an issue recently where I added a change to a before_validation to remove extraneous characters from phone numbers. I already had a ton of numbers in the system, so I thought I would then be able to just iteration through the list of phone numbers and resave them, and voila&amp;#8230; my data would be updated and I could then enable additional validation checks.&lt;/p&gt;

&lt;p&gt;Nothing happened. After a bit of digging I realized that Rails was assuming that nothing was changing because the new phone number value was the same as the old value so no save was occurring and validations (and before_validation hooks) were not being run. Turning off partial updates temporarily in the console allowed me to resave my data and have the new before_validation hook massage my data.&lt;/p&gt;

&lt;script src="https://gist.github.com/745337.js"&gt; &lt;/script&gt;</description><link>http://neutronflux.net/post/2349799138</link><guid>http://neutronflux.net/post/2349799138</guid><pubDate>Fri, 17 Dec 2010 10:44:17 -0700</pubDate><category>rails</category><category>active_record</category></item><item><title>Shoulda Snippets For Emacs</title><description>&lt;p&gt;I have just updated my &lt;a href="http://github.com/rwc9u/yasnippets-shoulda/tree/master"&gt;Shoulda snippets&lt;/a&gt; for the Emacs &lt;a href="http://yasnippet.googlecode.com/svn/trunk/doc/index.html"&gt;YASnippets templating package&lt;/a&gt;. &lt;a href="http://thoughtbot.com/projects/shoulda/"&gt;Shoulda&lt;/a&gt; is a ruby-based testing framework that consists of test macros, assertions, and helpers added on to the Test::Unit ruby framework. The snippets are based, and in many cases copied from the &lt;a href="http://svn.textmate.org/trunk/Review/Bundles/Ruby%20Shoulda.tmbundle/"&gt;TextMate Shoulda snippet bundle&lt;/a&gt;, and modified where needed to work with the YASnippets package. New features in the recently released 0.6beta of YASnippet allow support for more of the TextMate-based snippets. The new YASnippet functionality is discussed in more detail in a post I did on &lt;a href="http://www.emacsblog.org/2009/07/27/yasnippet-updated-supports-nested-placeholders-and-more/"&gt;Emacs Blog&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In order to port many of the snippets over from the TextMate bundle I wrote a &lt;a href="http://gist.github.com/154445"&gt;script&lt;/a&gt; that automates the process. There is a &lt;a href="http://code.nokrev.com/?p=snippet-copier.git;a=blob_plain;f=snippet_copier.py"&gt;Python script&lt;/a&gt; that does something very similar. The writing of my script was more of just a code kata for me, so take a look at both. One may be more suitable for your needs.&lt;/p&gt;</description><link>http://neutronflux.net/post/792723925</link><guid>http://neutronflux.net/post/792723925</guid><pubDate>Mon, 27 Jul 2009 22:00:00 -0600</pubDate></item><item><title>Better Oracle Support For db:structure:dump</title><description>&lt;p&gt;If you have tried&lt;/p&gt;

&lt;pre lang="console"&gt;&lt;code&gt;
$ rake db:structure:dump
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;in a rails app when using Oracle as your database, then you have probably been slightly disappointed. The same rake task for MySQL and Postgres dumps everything you need to recreate the database. The task for Oracle only dumps SQL for the table creation (no constraints), and for the sequences. The &amp;#8220;active_record_oracle_extensions&amp;#8221;:http://github.com/eyestreet/active_record_oracle_extensions/tree/master plug now supports dumping sql for the following:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;primary keys&lt;/li&gt;&lt;li&gt;indexes&lt;/li&gt;&lt;li&gt;foreign keys&lt;/li&gt;&lt;li&gt;synonyms&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;I have added enough functionality to scratch my itch. If you need something else or find a bug let me know.&lt;/p&gt;</description><link>http://neutronflux.net/post/792712939</link><guid>http://neutronflux.net/post/792712939</guid><pubDate>Sun, 22 Feb 2009 22:00:00 -0700</pubDate><category>ruby</category><category>programming</category><category>plugins</category><category>oracle</category></item><item><title>active_record_oracle_extensions Plugin</title><description>&lt;p&gt;The &amp;#8220;active_record_oracle_extensions plugin&amp;#8221;:http://github.com/eyestreet/active_record_oracle_extensions/tree/master provides support for adding foreign keys to migrations, adding synonyms to migrations, and disabling foreign key constraints during fixture loading. These are features that I needed in my applications, but either did not exist in other plugins, or the plugins seem to have been abandoned.&lt;/p&gt;

&lt;h3&gt;Installing into a Rails app&lt;/h3&gt;

&lt;pre lang="console"&gt;
$ script/plugin install git://github.com/eyestreet/active_record_oracle_extensions.git 
&lt;/pre&gt;

&lt;h3&gt;Adding Foreign Keys In a Migration&lt;/h3&gt;

&lt;p&gt;The example below shows a snippet from a migration that adds a foreign key.&lt;/p&gt;

&lt;pre lang="ruby"&gt;&lt;code class="ruby"&gt;
def self.up
    create_table :assets, :force =&amp;gt; true do |t|
      t.integer :media_record_id
      t.string  :media_file_name
      t.string  :media_content_type
      t.integer :media_file_size
      t.datetime :media_updated_at
      t.timestamps
    end
    add_foreign_key_constraint :assets, :media_record_id, 
                                        :media_records, :id
 end
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Adding a Synonym in Migration&lt;/h3&gt;

&lt;p&gt;The example below shows the creation of a synonym named events for other_user.events. The force option adds &amp;#8220;or replace&amp;#8221; to the sql that generates the synonym. It is assumed that the user under which your are creating the synonym already has the needed grants to allow the creation of the synonym on other_user.&lt;/p&gt;

&lt;pre lang="ruby"&gt;&lt;code class="ruby"&gt;
add_synonym :events, :other_user, :events, :force =&amp;gt; true
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Disabling Constraints During Fixture Loading&lt;/h3&gt;

&lt;p&gt;If you are using sys or system as your user for your rails application, then &lt;em&gt;do not use this plugin&lt;/em&gt;, or use it at your own risk. During fixture loading, this plugin disables constraints for the user that has established the connection to oracle, and then re-enables the constraints after the load.&lt;/p&gt;</description><link>http://neutronflux.net/post/792701437</link><guid>http://neutronflux.net/post/792701437</guid><pubDate>Thu, 01 Jan 2009 22:00:00 -0700</pubDate><category>oracle</category><category>plugins</category><category>programming</category><category>ruby</category></item></channel></rss>

