<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Greg Moreno &#187; rails</title>
	<atom:link href="http://gregmoreno.wordpress.com/tag/rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://gregmoreno.wordpress.com</link>
	<description>think BIG, act small</description>
	<lastBuildDate>Fri, 10 Feb 2012 22:36:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='gregmoreno.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Greg Moreno &#187; rails</title>
		<link>http://gregmoreno.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://gregmoreno.wordpress.com/osd.xml" title="Greg Moreno" />
	<atom:link rel='hub' href='http://gregmoreno.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Preventing model explosion via Rails serialization</title>
		<link>http://gregmoreno.wordpress.com/2011/01/27/preventing-model-explosion-via-rails-serialization/</link>
		<comments>http://gregmoreno.wordpress.com/2011/01/27/preventing-model-explosion-via-rails-serialization/#comments</comments>
		<pubDate>Thu, 27 Jan 2011 02:33:25 +0000</pubDate>
		<dc:creator>Greg Moreno</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://gregmoreno.wordpress.com/?p=420</guid>
		<description><![CDATA[A great thing about ActiveRecord is you can easily add a new model to your application and play around with it as you progress. However, this power can easily be overused leading to unnecessary overhead in your code. Consider the case where you have preferences for each user. For example, a user may opt to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gregmoreno.wordpress.com&amp;blog=5062655&amp;post=420&amp;subd=gregmoreno&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>  A great thing about ActiveRecord is you can easily add a new model to your application and play around with it as you progress. However, this power can easily be overused leading to unnecessary overhead in your code.</p>
<p>  Consider the case where you have preferences for each user. For example, a user may opt to show or hide his email address, adjust his timezone, or language. One solution is to simply add new columns to the users table that correspond to each preference type. For example, you can have a &#8216;show_email&#8217;, &#8216;timezone&#8217;, &#8216;locale&#8217; columns in the &#8216;users&#8217; table, which can make your table become wide as you add more preferences options.  Another option is to use a separate &#8216;preferences&#8217; table.</p>
<p>  <pre class="brush: ruby;">
  class User &lt; ActiveRecord::Base
    has_many :preferences
  end

  class Preferences &lt; ActiveRecord::Base
    belongs_to :user

    # name  - preference name
    # value - preference value
  end
  </pre></p>
<p>  Note there is no user interface to add or remove &#8216;preferences&#8217;, i.e. the kinds of preferences are fixed. Of course, in the future you may add a new kind of preference but this kind of work is better done outside of the user interface. Since that is the case, there is no need to represent &#8216;preferences&#8217; as a separate model.</p>
<p>  One better alternative is to use Rails serialization to store the different kinds and user-specific values. The code would look like this:</p>
<p>  <pre class="brush: ruby;">
  class User &lt; ActiveRecord::Base
    serialize :preferences, Hash
  end

  u = User.new
  u.preferences = {:show_email =&gt; true, :locale =&gt; :en }
  u.save

  # somewhere in your view using haml
  - if @user.preferences[:show_email]
    = @user.email
  </pre></p>
<p>  Using &#8216;serialize&#8217; results in less code, fewer tables, and less overall complexity. However, with serialization you lose the ability to efficiently search the preferences data. The million-dollar question is do you need to query these preferences? Do you need a finder that returns all users who wants to show their email?</p>
<p>  One issue I had with &#8216;serialize&#8217; is that by using it, I expose the implementation details. In the display example above, it is obvious I had it stored as a Hash. I would rather hide this detail and present the preferences attributes as user attributes instead. I also want default values for every user.</p>
<p>  For example:</p>
<p>  <pre class="brush: ruby;">
  u = User.new  # automatically assigns the default preferences
  u.preferences
  =&gt; {:show_email =&gt; false, :locale =&gt; :en}

  u.show_email = true  # I can change it like an attribute via @user.update_attributes(params[:user])
  u.preferences
  =&gt; {:show_email =&gt; true, :locale =&gt; :en}
  </pre></p>
<p>  I have created a module to support this. It is not a unique problem so others may have probably released a gem or plugin to do this. (I actually never bothered to search for one.) Nevertheless, it was a good exercise in metaprogramming.</p>
<p>  To use my implementation, simply call &#8216;serializeable&#8217; with the column you want to serialize and the default values. </p>
<p>  <pre class="brush: ruby;">
  class User &lt; ActiveRecord::Base
    serializeable :preferences, :show_email =&gt; true, :locale =&gt; :en
  end
  </pre></p>
<p>  Below is the implementation of &#8216;serializeable&#8217;. The convention is to save it under your &#8216;lib&#8217; folder and include it in your &#8216;config/application.rb&#8217; if you are using Rails 3. </p>
<p>  <pre class="brush: ruby;">
  module AttributeSerializer
  
    module ActiveRecordExtensions
      
      module ClassMethods
  
        def serializeable(serialized, serialized_accessors={})  
          serialize serialized, serialized_accessors.class
  
          serialized_attr_accessor serialized, serialized_accessors
          default_serialized_attr serialized,  serialized_accessors
        end
  
        # Creates the accessors
        def serialized_attr_accessor(serialized, accessors)
          accessors.keys.each do |k|
            define_method(&quot;#{k}&quot;) do
              self[serialized] &amp;&amp; self[serialized][k]
            end
  
            define_method(&quot;#{k}=&quot;) do |value|
              self[serialized][k] = value
            end
          end
        end
  
        # Sets the default value of the serialized field
        def default_serialized_attr(serialized, accessors)
          method_name =  &quot;set_default_#{serialized}&quot;
          after_initialize method_name 
  
          define_method(method_name) do
            self[serialized] = accessors if self[serialized].nil?
          end
        end
  
      end
  
    end
  
  end
  
  class ActiveRecord::Base
    extend AttributeSerializer::ActiveRecordExtensions::ClassMethods
  end
  </pre></p>
<p>  ActiveRecord is both easy and powerful. It can also lead to misuse and abuse. Even though you are adding just one model, remember that it is not just the model class itself. You are also adding the database migrations, unit tests, factories, finders, and validations that go along with the model. Next time you have a new requirement, see if serialization can do a better job.</p>
<p>  <strong>Update</strong>: Adam Cuppy converted this <a href="https://github.com/DYE/has_serialized">code into a Rails plugin</a> while Jay added <a href="https://gist.github.com/842797">dynamic finder methods</a>. I also moved this into a gem I called &#8216;<a href="https://github.com/gregmoreno/fancy_serializer">fancy_serializer</a>&#8216;. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gregmoreno.wordpress.com/420/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gregmoreno.wordpress.com/420/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gregmoreno.wordpress.com/420/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gregmoreno.wordpress.com/420/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gregmoreno.wordpress.com/420/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gregmoreno.wordpress.com/420/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gregmoreno.wordpress.com/420/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gregmoreno.wordpress.com/420/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gregmoreno.wordpress.com/420/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gregmoreno.wordpress.com/420/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gregmoreno.wordpress.com/420/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gregmoreno.wordpress.com/420/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gregmoreno.wordpress.com/420/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gregmoreno.wordpress.com/420/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gregmoreno.wordpress.com&amp;blog=5062655&amp;post=420&amp;subd=gregmoreno&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gregmoreno.wordpress.com/2011/01/27/preventing-model-explosion-via-rails-serialization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ed357f6cb63c16d83b35fc29e5502e44?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">Greg</media:title>
		</media:content>
	</item>
		<item>
		<title>Rails 3 upgrade part 4: Prototype helpers and Javascript</title>
		<link>http://gregmoreno.wordpress.com/2010/08/24/rails-3-upgrade-part-4-prototype-helpers-and-javascript/</link>
		<comments>http://gregmoreno.wordpress.com/2010/08/24/rails-3-upgrade-part-4-prototype-helpers-and-javascript/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 03:20:46 +0000</pubDate>
		<dc:creator>Greg Moreno</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://gregmoreno.wordpress.com/?p=441</guid>
		<description><![CDATA[Rails 3 is embracing the unobtrusive Javascript (or UJS) mantra which is good because it is the right way; at the same time, it is bad because many applications will break when they upgrade to Rails 3. On the other hand, who&#8217;s expecting a smooth upgrade anyway In my test application, I used jrails because [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gregmoreno.wordpress.com&amp;blog=5062655&amp;post=441&amp;subd=gregmoreno&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>  Rails 3 is embracing the <a href="http://en.wikipedia.org/wiki/Unobtrusive_JavaScript">unobtrusive Javascript (or UJS)</a> mantra which is good because it is the right way; at the same time, it is bad because many applications will break when they upgrade to Rails 3. On the other hand, who&#8217;s expecting a smooth upgrade anyway <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>  In my test application, I used jrails because I am more interested in jQuery than Prototype. But since <a href="http://www.railsplugins.org/plugins/264-jrails">jrails doesn&#8217;t work with Rails 3</a>, I removed it.</p>
<p>  When jrails was removed, I received this error:</p>
<p>  <pre class="brush: ruby;">
  undefined method `observe_field' for #&lt;#&lt;Class:0xb6867e58&gt;:0xb6865b6c&gt;
</pre>  </p>
<p>  <strong>Install Prototype helper plugin</strong></p>
<p>  &#8216;<a href="http://apidock.com/rails/ActionView/Helpers/PrototypeHelper/observe_field">observe_field&#8217; is a Prototype helper</a> and Rails 3 removed the the link between its Javascript helpers and Prototype. The goal in Rails 3 is for developers to use their preferred Javascript library. Also note that  remote_#{method} helpers have been removed from Rails and moved to <a href="http://github.com/rails/prototype_legacy_helper">Prototype Legacy Helper plugin</a> . To install this plugin, just do:</p>
<p>  <pre class="brush: ruby;">
  rails plugin install git://github.com/rails/prototype_legacy_helper
</pre></p>
<p>  <strong>Remove jQuery</strong></p>
<p>  Once the prototype_legacy_helper is installed, the missing method is gone but observe_field is not triggering. Removing jQuery fixes this problem.</p>
<p>  Now what if you want to use jQuery instead of Prototype? It depends how dependent your application is to Prototype. I have not found a jQuery equivalent for Prototype helper plugin yet so that would be an issue like in my case. Based on this <a href="http://blog.bernatfarrero.com/jquery-and-rails-3-mini-tutorial/">jQuery and Rails 3 tutorial</a>, using the jQuery UJS driver looks very easy. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gregmoreno.wordpress.com/441/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gregmoreno.wordpress.com/441/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gregmoreno.wordpress.com/441/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gregmoreno.wordpress.com/441/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gregmoreno.wordpress.com/441/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gregmoreno.wordpress.com/441/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gregmoreno.wordpress.com/441/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gregmoreno.wordpress.com/441/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gregmoreno.wordpress.com/441/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gregmoreno.wordpress.com/441/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gregmoreno.wordpress.com/441/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gregmoreno.wordpress.com/441/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gregmoreno.wordpress.com/441/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gregmoreno.wordpress.com/441/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gregmoreno.wordpress.com&amp;blog=5062655&amp;post=441&amp;subd=gregmoreno&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gregmoreno.wordpress.com/2010/08/24/rails-3-upgrade-part-4-prototype-helpers-and-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ed357f6cb63c16d83b35fc29e5502e44?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">Greg</media:title>
		</media:content>
	</item>
		<item>
		<title>Rails 3 upgrade part 3: Code fixes, views, and forms</title>
		<link>http://gregmoreno.wordpress.com/2010/08/13/rails-3-upgrade-part-3-code-fixes-views-and-forms/</link>
		<comments>http://gregmoreno.wordpress.com/2010/08/13/rails-3-upgrade-part-3-code-fixes-views-and-forms/#comments</comments>
		<pubDate>Fri, 13 Aug 2010 03:23:16 +0000</pubDate>
		<dc:creator>Greg Moreno</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://gregmoreno.wordpress.com/?p=443</guid>
		<description><![CDATA[This is part 3 of my Rails 2 to Rails 3 upgrade experience. Part 1 is about the initial code upgrade and getting the application to boot while part 2 deals with routes. While Part 2 is mainly about routes, getting it work involved changes in other parts of the code which I&#8217;ll share this [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gregmoreno.wordpress.com&amp;blog=5062655&amp;post=443&amp;subd=gregmoreno&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>  This is part 3 of my Rails 2 to Rails 3 upgrade experience. Part 1 is about the initial code upgrade and <a href="http://gregmoreno.ca/rails-3-upgrade-part-1-booting-the-application/">getting the application to boot</a> while <a href="http://gregmoreno.ca/rails-3-upgrade-part-2-routes/">part 2 deals with routes</a>. While Part 2 is mainly about routes, getting it work involved changes in other parts of the code which I&#8217;ll share this time. So while you are updating your routes, you may need to check this post in between changes.</p>
<p>  <strong>Update ApplicationController</strong></p>
<p>  After regenerating your application with rails (i.e. rails new appname -d dbadapter), your ApplicationController would look like this:</p>
<p>  <pre class="brush: ruby;">
  class ApplicationController &lt; ActionController::Base
    protect_from_forgery
  end
</pre></p>
<p>  There&#8217;s no need to panic because rails:upgrade:backup made a copy of the controller to application_controller.rb.rails2.</p>
<p>  If you have a lot of helper modules, you&#8217;ll most likely have this code in your Rails 2 ApplicationController:</p>
<p>  helper :all</p>
<p>  If you encounter a missing method error while monkey clicking your application, you probably forgot to update your Rails 3 ApplicationController.</p>
<p>  <strong>Update ApplicationHelper</strong></p>
<p>  The ApplicationHelper module was also modified by the rails upgrde. So don&#8217;t forget to update this, too.</p>
<p>  <strong>RAILS_* constants are deprecated is not entirely true</strong></p>
<p>  When you run rails:upgrade:check, it will list items you need to update including deprecated code. There is no need to change these as the word &#8216;deprecated&#8217; means but I encountered several &#8220;can&#8217;t convert nil into String&#8221; errors. </p>
<p>  <pre class="brush: bash;">
  rake rails:upgrade:check
  (in /mnt/hgfs/greg-mini/dev/projects/propsify)
  Deprecated constant(s)
  Constants like RAILS_ENV, RAILS_ROOT, and RAILS_DEFAULT_LOGGER are now deprecated.
  More information: http://litanyagainstfear.com/blog/2010/02/03/the-rails-module/
  
  The culprits: 
    ...
</pre></p>
<p>  The weird part is some constants are just doing fine.  In any case, here are the conversion:</p>
<p>  <pre class="brush: bash;">
  RAILS_ROOT  -&gt; Rails.root
  RAILS_ENV -&gt; Rails.env
  RAILS_DEFAULT_LOGGER -&gt; Rails.logger
</pre></p>
<p>  You can also check your environment the Ruby way:</p>
<p>  <pre class="brush: ruby;">
  # before
  if RAILS_ENV == 'production'
    ...
  
  # Rails 3
  if Rails.env.production?
</pre></p>
<p>  <strong>Output strings are automatically escaped</strong></p>
<p>  We should all be rejoicing that Rails is now serious about XSS protection except now your pages have become ugly with all those HTML tags. For example the code below will not give you a clickable link.</p>
<p>  <pre class="brush: ruby;">
  - signup = link_to('create one here', signup_path)
  = &quot;If you do not have an account, #{signup}.&quot;
</pre></p>
<p>  To fix this, use the raw() helper.</p>
<p>  <pre class="brush: ruby;">
  = raw &quot;If you do not have an account, #{signup}.&quot;
</pre></p>
<p>  Too bad for me, I got tons of views that were coded like this.</p>
<p>  <strong>Check for &#8216;concat&#8217;</strong></p>
<p>  A popular technique to simplify your view code is to use content blocks. You create a helper that takes a block and wraps it in some HTML tags. A simple implementation would look like this:</p>
<p>  <pre class="brush: ruby;">
  module LayoutHelper
    def main_column(options={}, &amp;amp;block)
      # calls column()
    end
  
    def column(options={}, &amp;amp;block)
      # concat is not needed in Rails 3
      concat content_tag(:div, capture(&amp;amp;block), options)
    end
  end
  
  # in your view
  - main_column do
    = render 'form'
</pre></p>
<p>  This works fine in Rails 2 but in Rails 3 the block gets outputted twice. <a href="http://apidock.com/rails/ActionView/Helpers/TextHelper/concat">concat</a> is the way to output text in a non-output block (i.e. &lt;% %&gt; in erb) but it seems like <a href="http://asciicasts.com/episodes/208-erb-blocks-in-rails-3">erb blocks in Rails 3 do not need concat</a>.</p>
<p>  <strong>Helpers with blocks</strong></p>
<p>  Before Rails 3, form_for or fields_for use non-output syntax; it means no equals sign. </p>
<p>  <pre class="brush: ruby;">
  # erb
  &lt;% form_for @offer do |f| %&gt;
    # ...
  &lt;% end %&gt;
  
  # haml
  - form_for @offer do |f|
    # ...
</pre></p>
<p>  In Rails 3, it should now be written as an output block.</p>
<p>  <pre class="brush: ruby;">
  # erb
  &lt;%= form_for @offer do |f| %&gt;
    # ...
  &lt;% end %&gt;
  
  # haml
  = form_for @offer do |f|
    = f.fields_for :items do |ff|
      # ...
</pre></p>
<p>  The rule is if the method is expected to return a string, it should use the output syntax. If it just <a href="http://edgeguides.rubyonrails.org/3_0_release_notes.html">buffering the returned string like content_for, it should NOT have the equals sign</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gregmoreno.wordpress.com/443/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gregmoreno.wordpress.com/443/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gregmoreno.wordpress.com/443/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gregmoreno.wordpress.com/443/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gregmoreno.wordpress.com/443/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gregmoreno.wordpress.com/443/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gregmoreno.wordpress.com/443/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gregmoreno.wordpress.com/443/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gregmoreno.wordpress.com/443/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gregmoreno.wordpress.com/443/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gregmoreno.wordpress.com/443/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gregmoreno.wordpress.com/443/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gregmoreno.wordpress.com/443/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gregmoreno.wordpress.com/443/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gregmoreno.wordpress.com&amp;blog=5062655&amp;post=443&amp;subd=gregmoreno&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gregmoreno.wordpress.com/2010/08/13/rails-3-upgrade-part-3-code-fixes-views-and-forms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ed357f6cb63c16d83b35fc29e5502e44?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">Greg</media:title>
		</media:content>
	</item>
		<item>
		<title>Rails 3 upgrade part 2: Routes</title>
		<link>http://gregmoreno.wordpress.com/2010/08/12/rails-3-upgrade-part-2-routes/</link>
		<comments>http://gregmoreno.wordpress.com/2010/08/12/rails-3-upgrade-part-2-routes/#comments</comments>
		<pubDate>Thu, 12 Aug 2010 03:25:30 +0000</pubDate>
		<dc:creator>Greg Moreno</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://gregmoreno.wordpress.com/?p=445</guid>
		<description><![CDATA[In the previous post, I outlined the steps I took to upgrade and boot a Rails 3 application. This time, I share my experience upgrading the routes file. By the way, I forgot to mention in the last post that I&#8217;m using Rails 3 Upgrade Handbook by Jeremy McAnally. The task rails:upgrade:routes (comes with the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gregmoreno.wordpress.com&amp;blog=5062655&amp;post=445&amp;subd=gregmoreno&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>  In the previous post, I outlined the steps I took to<a href="http://gregmoreno.ca/rails-3-upgrade-part-1-booting-the-application/"> upgrade and boot a Rails 3 application</a>. This time, I share my experience upgrading the routes file. By the way, I forgot to mention in the last post that I&#8217;m using <a href="http://www.railsupgradehandbook.com/">Rails 3 Upgrade Handbook by Jeremy McAnally</a>.</p>
<p>  The task rails:upgrade:routes (comes with the rails_upgrade plugin) converts your Rails 2 routes into Rails 3 format. It handles most cases but you may still need to edit the generated routes depending on your setup.</p>
<p>  <strong>map.root</strong></p>
<p>  Below, I show the old route and the generated version. </p>
<p>  <pre class="brush: ruby;">
  # Rails 2
  map.root :controller =&gt; 'search'
  
  # Rails 3
  match '/' =&gt; 'search#index'
</pre></p>
<p>  The conversion is correct but since I use the named route &#8216;root_path&#8217; in my application, I had to change it:</p>
<p>  <pre class="brush: ruby;">
  root :to =&gt; 'search#index'
</pre></p>
<p>  <strong>:as, :member, :any, :path_names</strong></p>
<p>  <pre class="brush: ruby;">
  # Rails 2
  map.resources :workspaces, :as =&gt; 'b', :member =&gt; { :widget =&gt; :get } do |workspace|
    # ...
  end
  
  # Rails 3
  resources :workspaces do
    # ...
  end
</pre></p>
<p>  In Rail 3, :as  is for overriding the normal naming for named routes witout affecting the path. For example, the code below will recognize the path &#8216;/workspaces&#8217; and the named route becomes offices_path.</p>
<p>  <pre class="brush: ruby;">
  resources :workspaces, :as =&gt; 'offices'
</pre></p>
<p>  In Rails 2, :as affects the path. In my example, &#8216;/b&#8217; routes the request to WorkspacesController. So for Rails 3 to recognize the path &#8216;/b&#8217;, I need to add another route.</p>
<p>  <pre class="brush: ruby;">
  match 'b' =&gt; 'workspaces#index'
</pre></p>
<p>  The rails:upgrade:routes did not convert the following member route and had to be added.</p>
<p>  <pre class="brush: ruby;">
  :member =&gt; { :widget =&gt; :get } 
</pre></p>
<p>  The new route becomes:</p>
<p>  <pre class="brush: ruby;">
  resources :workspaces do
    get :widget, :on =&gt; :member
  end
</pre></p>
<p>  In Rails 2, you can use the :any option to define a custom route that responds to any request method. </p>
<p>  <pre class="brush: ruby;">
  # Rails 2
  workspace.resource :twitter_account, :member =&gt; { :authorize =&gt; :any }, :path_names =&gt; { :edit =&gt; 'request_authorization' }
  
  # generated by rails:upgrade:routes
  resource :twitter_account do
    member do
      any :authorize
    end
  end
</pre></p>
<p>  The rails:upgrade:routes converted the :any option. However,  when I booted the application, it raised an exception:</p>
<p>  <pre class="brush: ruby;">
  undefined method 'any' for #&lt;ActionDispatch::Routing::Mapper:0xb71b6fcc&gt; (NoMethodError)
</pre></p>
<p>  To fix this, I replaced the offending line with a match method.</p>
<p>  <pre class="brush: ruby;">
  resource :twitter_account do
    match :authorize, :on =&gt; :member
  end
</pre></p>
<p>  :path_names was also not included in the generated route so has to be added as well.</p>
<p>  <pre class="brush: ruby;">
  resource :twitter_account, :path_names =&gt; { :edit =&gt; 'request_authorization' } do
    match :authorize, :on =&gt; :member
  end
</pre></p>
<p>  <strong>Specifying a different controller</strong></p>
<p>  <pre class="brush: ruby;">
  # Rails 2
  map.resource :settings, :controller =&gt; 'users' do |settings|
    settings.resource :twitter_account, :name_prefix =&gt; nil, :member =&gt; { :authorize =&gt; :any }, :path_names =&gt; { :edit =&gt; 'request_authorization' }
  end
  
  # generated by rake:upgrade:routes
  resource :settings do
    resource :twitter_account do
      member do
        any :authorize
      end
    end
  end
</pre></p>
<p>  To fix, just specify the controller</p>
<p>  <pre class="brush: ruby;">
  resource :settings, :controller =&gt; :users do
    # ...
  end
</pre></p>
<p>  <strong>Undefined named route helper</strong></p>
<p>  I encountered this exception while trying the application:</p>
<p>  <pre class="brush: ruby;">
  undefined method 'edit_twitter_account_path'
</pre></p>
<p>  In Rails 2, this is the route that created this named route:</p>
<p>  <pre class="brush: ruby;">
  map.resource :settings, :controller =&gt; 'users' do |settings|
    settings.resource :twitter_account, :name_prefix =&gt; nil, :member =&gt; { :authorize =&gt; :any }, :path_names =&gt; { :edit =&gt; 'request_authorization' }
  end
</pre></p>
<p>  This is a bit tricky for me because I cannot remember why I nested it <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Nevertheless, to fix the Rails 3 error, I moved :twitter_account outside of :settings. The correct Rails routes now look like these:</p>
<p>  <pre class="brush: ruby;">
  resource :settings, :controller =&gt; :users
  resource :twitter_account, :path_names =&gt; { :edit =&gt; 'request_authorization' } do
    match :authorize, :on =&gt; :member
  end
</pre></p>
<p>  <strong>Custom polymorphic named route helper</strong></p>
<p>  A long time ago, I played around with polymorphic paths. In hindsight, that is a waste of time but back then it was fun or should I say a time well wasted. I have a named route helper that takes any object and used like this:</p>
<p>  <pre class="brush: ruby;">
  # in views
  link_to 'invitations', invitations_path(@voteable)
  
  # definition
  module RoutesHelper
    def invitations_path(voteable)
      send(&quot;#{voteable.class.name.underscore}_invitations_path&quot;, voteable)
    end
  
    def workspace_invitations_path(workspace)
      super(:workspace_id =&gt; workspace)
    end
  
    # ...
  end
</pre></p>
<p>  In Rails 3, my named route helper is not being called. Thus, wrong URL is generated. I know, I know it should have been a simple <a href="http://api.rubyonrails.org/classes/ActionController/PolymorphicRoutes.html">polymorphic_path</a> call but I still wonder why my method is not called. Moving on, the new ruby is:</p>
<p>  <pre class="brush: ruby;">
  link_to 'invitations', polymorphic_path([@voteable, :invitations])
</pre></p>
<p>  I cheated a bit here because I want this post to focus on routes. Along the way, I had to update non-route related code to discover the route problems. <a href="http://edgeguides.rubyonrails.org/routing.html">You can learn more about Rails 3 routes from this RailsGuides page</a>.</p>
<p>  There are still more updates to be done and I&#8217;ll share them in other posts. Just like your favorite late night infomercial, &#8220;Wait! There&#8217;s more&#8221;.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gregmoreno.wordpress.com/445/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gregmoreno.wordpress.com/445/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gregmoreno.wordpress.com/445/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gregmoreno.wordpress.com/445/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gregmoreno.wordpress.com/445/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gregmoreno.wordpress.com/445/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gregmoreno.wordpress.com/445/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gregmoreno.wordpress.com/445/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gregmoreno.wordpress.com/445/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gregmoreno.wordpress.com/445/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gregmoreno.wordpress.com/445/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gregmoreno.wordpress.com/445/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gregmoreno.wordpress.com/445/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gregmoreno.wordpress.com/445/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gregmoreno.wordpress.com&amp;blog=5062655&amp;post=445&amp;subd=gregmoreno&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gregmoreno.wordpress.com/2010/08/12/rails-3-upgrade-part-2-routes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ed357f6cb63c16d83b35fc29e5502e44?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">Greg</media:title>
		</media:content>
	</item>
		<item>
		<title>Rails 3 upgrade part 1: Booting the application</title>
		<link>http://gregmoreno.wordpress.com/2010/08/11/rails-3-upgrade-part-1-booting-the-application/</link>
		<comments>http://gregmoreno.wordpress.com/2010/08/11/rails-3-upgrade-part-1-booting-the-application/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 03:27:20 +0000</pubDate>
		<dc:creator>Greg Moreno</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://gregmoreno.wordpress.com/?p=447</guid>
		<description><![CDATA[It&#8217;s time for another Rails upgrade! We all have our share of bad experiences and frustrations every time we upgrade a piece of software. Even for technical people who live and breath on the edge, upgrades are one of these things we try to avoid as much as possible. Still, there is always a sense [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gregmoreno.wordpress.com&amp;blog=5062655&amp;post=447&amp;subd=gregmoreno&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>  It&#8217;s time for another Rails upgrade! We all have our share of bad experiences and frustrations every time we upgrade a piece of software. Even for technical people who live and breath on the edge, upgrades are one of these things we try to avoid as much as possible.  Still, there is always a sense of excitement in trying something new even if it adds problems to an already stable piece of code.</p>
<p>  For a little background, I am upgrading a Rails app several of friends and I have written last year. The code is available at <a href="http://github.com/gregmoreno/propsify">github</a>.</p>
<p>  In this post, I share the steps I did to boot the application. This doesn&#8217;t mean the upgrade went fine neither the app is ready to go. It only means all the required initialization are OK. In succeeding posts, I share my experiences in upgrading the app to a green state.</p>
<p>  First, my environment.</p>
<p>  <pre class="brush: bash;">
  greg@piccolo:~/dev/projects/propsify3$ rvm info
  ruby-1.8.7-p299@propsify:
  
    system:
      uname:        &quot;Linux piccolo 2.6.31-22-generic #61-Ubuntu SMP Wed Jul 28 01:57:06 UTC 2010 i686 GNU/Linux&quot;
      shell:        &quot;bash&quot;
      version:      &quot;4.0.33(1)-release&quot;
  
    rvm:
      version:      &quot;rvm 0.1.44 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/]&quot;
  
    ruby:
      interpreter:  &quot;ruby&quot;
      version:      &quot;1.8.7&quot;
      date:         &quot;2010-06-23&quot;
      platform:     &quot;i686-linux&quot;
      patchlevel:   &quot;2010-06-23 patchlevel 299&quot;
      full_version: &quot;ruby 1.8.7 (2010-06-23 patchlevel 299) [i686-linux]&quot;
  
  greg@piccolo:~/dev/projects/propsify3$ script/about
  About your application's environment
  Ruby version              1.8.7 (i686-linux)
  RubyGems version          1.3.7
  Rack version              1.0 bundled
  Rails version             2.3.2
  Active Record version     2.3.2
  Action Pack version       2.3.2
  Active Resource version   2.3.2
  Action Mailer version     2.3.2
  Active Support version    2.3.2
  Application root          /mnt/hgfs/greg-mini/dev/projects/propsify
  Environment               development
  Database adapter          postgresql
  Database schema version   20100113032723
  
  
  greg@piccolo:~/dev/projects/propsify3$ gem list
  
  *** LOCAL GEMS ***
  
  actionmailer (2.3.2)
  actionpack (2.3.2)
  activerecord (2.3.2)
  activeresource (2.3.2)
  activesupport (2.3.2)
  geokit (1.5.0)
  json (1.4.5)
  mime-types (1.16)
  oauth (0.4.1)
  pg (0.9.0)
  rails (2.3.2)
  rake (0.8.7)
  RedCloth (4.2.2)
  twitter_oauth (0.3.2)
  
  greg@piccolo:~/dev/projects/propsify3$ ls vendor/gems/
  authlogic-2.1.3  geokit-1.5.0  haml-2.2.16  macaddr-1.0.0  twitter_oauth-0.3.2  uuid-2.1.0
  
  greg@piccolo:~/dev/projects/propsify3$ ls vendor/plugins/
  acts_as_commentable        geokit-rails     is_taggable   thinking-sphinx      will_paginate
  declarative_authorization  gravatar-plugin  jrails        validates_date_time
  exception_notification     haml             subdomain-fu  vote_fu
  
</pre></p>
<p>  <strong>Step 1: Install rails 3</strong></p>
<p>  gem install rails &#8211;pre</p>
<p>  <strong>Step 2: Install the plugin tool </strong></p>
<p>  script/plugin install git://github.com/rails/rails_upgrade.git</p>
<p>  <strong>Step 3: Show upgrade checklist</strong></p>
<p>  rake rails:upgrade:check</p>
<p>  This task lists the items you should watch out for when doing the upgrade. You don&#8217;t need to fix everything right away (some are deprecation notice) but review the checklist nevertheless.</p>
<p>  <strong>Step 4: Generate the new routes</strong></p>
<p>  rake rails:upgrade:routes</p>
<p>  This task reads the current config/routes.rb and outputs a Rails 3 version.<br />
  Don&#8217;t worry, it doesn&#8217;t override your routes file. Keep this in a safe place for later use.</p>
<p>  <strong>IMPORTANT:</strong> I actually didn&#8217;t realize I did the right thing until after the actual code upgrade. When I tried generating the new routes after the code change, it outputted an empty block. I have no idea if this is unique to my case but just to be sure, generate the routes beforehand and keep a copy.</p>
<p>  <strong>Step 5: Create Gemfiles</strong></p>
<p>  rails:upgrade:gems</p>
<p>  Next is to generate the file &#8216;Gemfile&#8217;. In Rails 2, the gems you need are listed in config/environment.rb while in Rails 3 the gems are listed in the Gemfile. Gemfile is used by the program &#8216;bundler&#8217; to manage the gems required by your application. Unfortunately, this task didn&#8217;t include the gems I listed in environment.rb so I have to add it later.</p>
<p>  <strong>Step 6: Backup your files</strong></p>
<p>  rails:upgrade:backup</p>
<p>  I hope you are working on another branch (or a copy) but just in case you are not, run this task to make copies of the files that will be affected during the upgrade.</p>
<p>  Now comes the juicy part. </p>
<p>  <strong>Step 7: Generate the Rails 3 app on top of your Rails 2 app</strong></p>
<p>  rails new propsify3 -d postgresql</p>
<p>  Run this command in your app&#8217;s parent folder. In my case, my app&#8217;s name and pathname is &#8216;propsify3&#8242; and I am using postgresql as my database. This command created and replaced a bunch of files. Since you&#8217;ve backed-up everything, there&#8217;s nothing to worry. </p>
<p>  <strong>Step 8: Move code from environment.rb to application.rb</strong></p>
<p>  Your new config/environment.rb file looks like it went through a rigorous diet. You can leave this file for now. What is important now is you move the initializer code from your config/environment.rb.rails2 to config/application.rb.  These are the config.* lines except the config.gem which goes to Gemfile.</p>
<p>  <strong>Step 9: Convert the new routes</strong></p>
<p>  You can still use the existing routes until 3.1 but since there&#8217;s a tool to help you migrate, I suggest doing it. At this point, when I tried the rails:upgrade:routes, no routes were generated. So make sure you generate the routes before Step 7.</p>
<p>  <strong>Step 10: Delete new_rails_defaults.rb </strong></p>
<p>  rm config/initializers/new_rails_defaults</p>
<p>  <strong>Step 11: Upgrade the plugins and gems</strong></p>
<p>  Many plugins are now available as gems. Check your plugins and gems at <a href="http://railsplugins.org">http://railsplugins.org</a>. In my case, the following plugins were converted to gems:</p>
<p>  acts_as_commentable<br />
  declarative_authorization<br />
  haml<br />
  will_paginate<br />
  thinking-sphinx</p>
<p>  Unfortunately, the plugins below are not yet ready for Rails 3. I removed them for now and all code that references them.</p>
<p>  jrails<br />
  subdomain-fu<br />
  vote_fu</p>
<p>  <strong>IMPORTANT</strong>: In your Gemfile, make sure you check specify the right version that is compatible with Rails 3. Some gems are still in the pre-release version and will  not be downloaded if you don&#8217;t specify a version in your Gemfile. For example, this is a snippet from my Gemfile:</p>
<p>  <pre class="brush: ruby;">
  gem 'pg'
  gem 'acts_as_commentable'
  gem 'declarative_authorization'
  gem 'haml'
  gem 'thinking-sphinx', '2.0.0.rc1', :require =&gt; 'thinking_sphinx'
  gem 'will_paginate', '3.0.pre2'
  gem 'uuid'
  gem 'geokit'
</pre></p>
<p>  <strong>Step 12: Update initialization code</strong></p>
<p>  After step 10 you are good to go, if you&#8217;re lucky. In my case, I had to remove some patches and change code to boot the application.</p>
<p>  ActiveSupport::CoreExtensions::Date::Conversions::DATE_FORMATS.merge!(date_time_formats)</p>
<p>  This fails in Rails 3 because core extensions have been moved out of their modules and are now included in classes they extend. For example, to fix the date format problem do:</p>
<p>  Date::DATE_FORMATS.merge!(date_time_formats)</p>
<p>  <strong>Step 13: Boot the app</strong></p>
<p>  rails server</p>
<p>  Yay! If you are wondering what happened to <code>script/server</code> command,  Rails went the &#8220;Merb way&#8221; and consolidated the <code>script/*</code> commands into  the <code>rails</code> script.</p>
<p>  By now, you should see the famous Rails&#8217; &#8220;Welcome aboard&#8221; message in your browser. </p>
<p>  <strong>Step 14: Remove public/index.html</strong></p>
<p>  Now, you can try if your application is working.</p>
<p>  There are still more work to do like moving to the ActiveRecord/ActiveRelation API and removing the deprecation notices. Before moving on, I still need to fix the problems in my routes and unsupported gems which I will tackle in my next post.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gregmoreno.wordpress.com/447/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gregmoreno.wordpress.com/447/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gregmoreno.wordpress.com/447/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gregmoreno.wordpress.com/447/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gregmoreno.wordpress.com/447/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gregmoreno.wordpress.com/447/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gregmoreno.wordpress.com/447/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gregmoreno.wordpress.com/447/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gregmoreno.wordpress.com/447/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gregmoreno.wordpress.com/447/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gregmoreno.wordpress.com/447/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gregmoreno.wordpress.com/447/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gregmoreno.wordpress.com/447/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gregmoreno.wordpress.com/447/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gregmoreno.wordpress.com&amp;blog=5062655&amp;post=447&amp;subd=gregmoreno&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gregmoreno.wordpress.com/2010/08/11/rails-3-upgrade-part-1-booting-the-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ed357f6cb63c16d83b35fc29e5502e44?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">Greg</media:title>
		</media:content>
	</item>
	</channel>
</rss>
