<?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/"
	>

<channel>
	<title>Sean&#039;s Blog &#187; plugins</title>
	<atom:link href="http://seanbehan.com/tag/plugins/feed/" rel="self" type="application/rss+xml" />
	<link>http://seanbehan.com</link>
	<description>Web Programming, Ruby on Rails, Wordpress, PHP from Burlington, Vermont</description>
	<lastBuildDate>Wed, 18 Jan 2012 21:44:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Hacking Rails Plugins</title>
		<link>http://seanbehan.com/programming/hacking-rails-plugins/</link>
		<comments>http://seanbehan.com/programming/hacking-rails-plugins/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 18:33:49 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[acts as taggable on]]></category>
		<category><![CDATA[load order]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[to_param]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=863</guid>
		<description><![CDATA[Using the Acts as Taggable On plugin to add categories to a model class, I wanted to override the to_param method and place the name attribute in the url. The plugin, installed as a gem, source shouldn&#8217;t need to be hacked in order to accomplish this. The solution is to add a plugin into the [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fprogramming%2Fhacking-rails-plugins%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Hacking Rails Plugins" data-url="http://seanbehan.com/programming/hacking-rails-plugins/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>Using the <a href="http://github.com/mbleigh/acts-as-taggable-on">Acts as Taggable On</a> plugin to add categories to a model class, I wanted to override the to_param method and place the name attribute in the url. The plugin, installed as a gem, source shouldn&#8217;t need to be hacked in order to accomplish this. The solution is to add a plugin into the RAILS_ROOT/vendor/plugins directory and append the plugin name with _hack. This will, because of an alphabetical load order, allow you to reopen the any class in the plugin. In my example</p>
<pre class="wp-code-highlight prettyprint">
# RAILS_ROOT/vendor/plugins/acts_as_taggable_on_hack/init.rb
Tag.class_eval do
  to_param
    &quot;#{id}-#{name.gsub(/[^a-z0-9]+/i, '-'/)
  end
end
</pre>
<p>Got this tip from <a href="http://errtheblog.com/posts/67-evil-twin-plugin">http://errtheblog.com/posts/67-evil-twin-plugin</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/programming/hacking-rails-plugins/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Rails Plugin Acts as Taggable on Steriods</title>
		<link>http://seanbehan.com/ruby-on-rails/rails-plugin-acts-as-taggable-on-steriods/</link>
		<comments>http://seanbehan.com/ruby-on-rails/rails-plugin-acts-as-taggable-on-steriods/#comments</comments>
		<pubDate>Tue, 02 Mar 2010 22:46:12 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[active record]]></category>
		<category><![CDATA[migration]]></category>
		<category><![CDATA[model]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[tags]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=831</guid>
		<description><![CDATA[You can download it here http://github.com/suitmymind/acts-as-taggable-on-steroids as well as read usage info (which is for the most part reprinted here). ./script/plugin install http://svn.viney.net.nz/things/rails/plugins/acts_as_taggable_on_steroids ./script/generate acts_as_taggable_migration rake db:migrate Then in your model class Post &#60; ActiveRecord::Base acts_as_taggable end And usage is as follows p = Post.find(:first) p.tag_list # [] p.tag_list = &#34;Funny, Silly&#34; p.save p.tag_list # [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fruby-on-rails%2Frails-plugin-acts-as-taggable-on-steriods%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Rails Plugin Acts as Taggable on Steriods" data-url="http://seanbehan.com/ruby-on-rails/rails-plugin-acts-as-taggable-on-steriods/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>You can download it here <a href="http://github.com/suitmymind/acts-as-taggable-on-steroids">http://github.com/suitmymind/acts-as-taggable-on-steroids</a> as well as read usage info (which is for the most part reprinted here).</p>
<pre class="wp-code-highlight prettyprint">
./script/plugin install http://svn.viney.net.nz/things/rails/plugins/acts_as_taggable_on_steroids
./script/generate acts_as_taggable_migration
rake db:migrate
</pre>
<p>Then in your model</p>
<pre class="wp-code-highlight prettyprint">
class Post &lt; ActiveRecord::Base
    acts_as_taggable
 end
</pre>
<p>And usage is as follows</p>
<pre class="wp-code-highlight prettyprint">
p = Post.find(:first)
p.tag_list # []
p.tag_list = &quot;Funny, Silly&quot;
p.save
p.tag_list # [&quot;Funny&quot;, &quot;Silly&quot;]
p.tag_list.add(&quot;Great&quot;, &quot;Awful&quot;)
p.tag_list.remove(&quot;Funny&quot;)

#to find...
Post.find_tagged_with('Funny, Silly')
Post.find_tagged_with('Funny, Silly', :match_all =&gt; true)
</pre>
<p>To use this in a form and let users enter a comma separated list of tag names&#8230;</p>
<pre class="wp-code-highlight prettyprint">
form_for @post do |f|
f.text_field :tag_list
</pre>
<p>And to get a tag cloud</p>
<pre class="wp-code-highlight prettyprint">
  #controller
  class PostController &amp;lt; ApplicationController
    def tag_cloud
      @tags = Post.tag_counts
    end
  end

  # and in view...
  &amp;lt;style&amp;gt;
  .css1 { font-size: 1.0em; }
  .css2 { font-size: 1.2em; }
  .css3 { font-size: 1.4em; }
  .css4 { font-size: 1.6em; }
  &amp;lt;/style&amp;gt;

  &amp;lt;% tag_cloud @tags, %w(css1 css2 css3 css4) do |tag, css_class| %&amp;gt;
    &amp;lt;%= link_to tag.name, { :action =&amp;gt; :tag, :id =&amp;gt; tag.name }, :class =&amp;gt; css_class %&amp;gt;
  &amp;lt;% end %&amp;gt;
</pre>
<p>*Note. If you have a controller &#8220;tags_controller.rb&#8221; and the auto generated (if you used ./script/generate) helper file &#8220;tags_helper.rb&#8221; you&#8217;ll need to make sure to copy the contents of the plugin lib module of the same name, into the helper file. You&#8217;ll get an error otherwise.</p>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/ruby-on-rails/rails-plugin-acts-as-taggable-on-steriods/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TinyMCE Rich Text Editor: HELLO EDITOR Plugin Tutorial and Example</title>
		<link>http://seanbehan.com/wordpress/tinymce-rich-text-editor-hello-editor-plugin-tutorial-and-example/</link>
		<comments>http://seanbehan.com/wordpress/tinymce-rich-text-editor-hello-editor-plugin-tutorial-and-example/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 19:26:52 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[text editor]]></category>
		<category><![CDATA[tinymce]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=598</guid>
		<description><![CDATA[I wanted to create a button for the TinyMCE Rich Text Editor for WordPress. It was tough to find good docs on the subject. There are a couple of useful posts out there but in general I found them lacking. http://codex.wordpress.org/TinyMCE_Custom_Buttons#Creating_an_MCE_Editor_Plugin The above resource has a good section on the PHP code needed to write [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fwordpress%2Ftinymce-rich-text-editor-hello-editor-plugin-tutorial-and-example%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="TinyMCE Rich Text Editor: HELLO EDITOR Plugin Tutorial and Example" data-url="http://seanbehan.com/wordpress/tinymce-rich-text-editor-hello-editor-plugin-tutorial-and-example/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>I wanted to create a button for the TinyMCE Rich Text Editor for WordPress. It was tough to find good docs on the subject. There are a couple of useful posts out there but in general I found them lacking.<br />
<a href=" http://codex.wordpress.org/TinyMCE_Custom_Buttons#Creating_an_MCE_Editor_Plugin"></p>
<p>http://codex.wordpress.org/TinyMCE_Custom_Buttons#Creating_an_MCE_Editor_Plugin</a></p>
<p>The above resource has a good section on the PHP code needed to write your own callbacks but there is no mention of the JavaScript required to create a button and interact with it. Links are available for more reading but why not also post a code sample to get up and running?</p>
<p>Anyway, I made a simple plugin after hobbling a bunch of resources together to get a button in the text editor that when clicked triggers an alert to the window. The code isn&#8217;t fancy but it might provide a starting off point for a larger project or be useful as a resource for some of the basic ideas involved. I read through a couple of the sample plugins included with WordPress along with the Viper Video Quicktags Plugin, which makes extensive use of the feature. However, they were too complex for a quick, basic understanding.</p>
<p>This plugin doesn&#8217;t do a lot. I&#8217;ll probably flesh it out a bit more when I have a clearer understanding of how it all works. For now here are some code samples and at the bottom of this post there is a link to the .zip file for the plugin which you can install on your own site.</p>
<p>In wp-content/plugins/hello_editor/index.php</p>
<pre class="wp-code-highlight prettyprint">&amp;lt;?php
/*
Plugin Name: Hello Editor
Plugin URI: http://seanbehan.com/wordpress/tinymce-rich-text-editor-hello-editor-plugin-tutorial-and-example/
Description: A simple plugin showing how to add a button to the rich text editor in WordPress.
The plugin doesn't do anything except place a button and respond to onclick event, with &quot;Hello Editor&quot;.
Most of the editor plugins available are too 'functional' to quickly read and see how to do the
basics. This plugin doesn't 'do' anything, rather it makes it simple to read what is going on.
Version: 0.1
Author: Sean Behan
Author URI: http://seanbehan.com
*/

define( &quot;HELLO_EDITOR_PLUGIN_DIR&quot;, &quot;hello_editor&quot; );
define( &quot;HELLO_EDITOR_PLUGIN_URL&quot;, &quot;/wp-content/plugins/&quot; . HELLO_EDITOR_PLUGIN_DIR );

// Register the external pllugin from the .js file
function hello_editor_register_external_plugin($plugin_array) {
  $plugin_array['HELLO_EDITOR'] = HELLO_EDITOR_PLUGIN_URL . '/editor_plugin.js';
  return $plugin_array;
}

// Add the button to the array ***NOTE*** The name here &quot;HELLO_EDITOR&quot; must
//match the name in the editor plugin file for the addButton(name_of_button) function!
function hello_editor_register_button($buttons) {
  array_push( $buttons, &quot;|&quot;, &quot;HELLO_EDITOR&quot; );
  return $buttons;
}

// Filters which will call our functions
function hello_editor_init(){
  add_filter(&quot;mce_external_plugins&quot;, &quot;hello_editor_register_external_plugin&quot;);
  add_filter('mce_buttons', 'hello_editor_register_button');
}

// When the editor is initialized
add_action('init', 'hello_editor_init');</pre>
<p>In wp-content/plugins/hello_editor/editor_plugin.js</p>
<pre class="wp-code-highlight prettyprint">(function() {
  //Init the plugin
  tinymce.create('tinymce.plugins.HELLO_EDITOR', {
    init : function( ed, url ) {
    //addButton name needs to match $plugin_array['HELLO_EDITOR'] in add_filter function
    ed.addButton('HELLO_EDITOR', {
      title : 'Hello Editor',
      image : url + &quot;/buttons/hello.png&quot;,
      onclick : function(){
        alert(&quot;HELLO EDITOR!&quot;);
      }
    });
  },
  //Info about the plugin
  getInfo : function() {
    return {
      longname : &quot;Sean Behan's Sample Hello Editor Plugin&quot;,
      author : 'Sean Behan',
      authorurl : 'http://www.seanbehan.com/',
      infourl : 'http://seanbehan.com/wordpress/tinymce-rich-text-editor-hello-editor-plugin-tutorial-and-example/',
      version : &quot;0.1&quot;
    };
  }
});
tinymce.PluginManager.add('HELLO_EDITOR', tinymce.plugins.HELLO_EDITOR);
})();</pre>
<p>You&#8217;ll also need a directory called buttons inside the hello_editor plugin directory with a hello.png file which will be displayed. Without it you&#8217;ll just get a blank button. You can rename this but remember to change the name in the editor_plugin.js file as well.</p>
<p>You can download the sample plugin here <a href="http://seanbehan.com/wp-content/uploads/2009/11/hello_editor.zip">http://seanbehan.com/wp-content/uploads/2009/11/hello_editor.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/wordpress/tinymce-rich-text-editor-hello-editor-plugin-tutorial-and-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails Paperclip Plugin Options for Attaching Files</title>
		<link>http://seanbehan.com/ruby-on-rails/rails-paperclip-plugin-options-for-attaching-files/</link>
		<comments>http://seanbehan.com/ruby-on-rails/rails-paperclip-plugin-options-for-attaching-files/#comments</comments>
		<pubDate>Fri, 16 Oct 2009 00:09:27 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[avatars]]></category>
		<category><![CDATA[file uploads]]></category>
		<category><![CDATA[options]]></category>
		<category><![CDATA[paperclip]]></category>
		<category><![CDATA[plugins]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=582</guid>
		<description><![CDATA[I usually change some of the default settings when I use the Paperclip plugin. For most of my projects I don&#8217;t like having separate directories for each image that is uploaded. I prefer, in this instance, to put avatars of different sizes together under one directory and differentiated based on the style size of the [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fruby-on-rails%2Frails-paperclip-plugin-options-for-attaching-files%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Rails Paperclip Plugin Options for Attaching Files" data-url="http://seanbehan.com/ruby-on-rails/rails-paperclip-plugin-options-for-attaching-files/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>I usually change some of the default settings when I use the Paperclip plugin. For most of my projects I don&#8217;t like having separate directories for each image that is uploaded. I prefer, in this instance, to put avatars of different sizes together under one directory and differentiated based on the style size of the image. To do this just set the path and url options like so&#8230;</p>
<pre class="wp-code-highlight prettyprint">
  has_attached_file :avatar,
    :styles =&gt; {:thumb =&gt; &quot;75x75&quot;, :medium =&gt; &quot;150x150&quot;, :large =&gt; &quot;500x500&quot;},
    :default_url =&gt; &quot;/images/default_avatar.png&quot;,
    :url =&gt; &quot;/system/avatars/:id/:style_:basename.:extension&quot;,
    :path =&gt; &quot;:rails_root/public/system/avatars/:id/:style_:basename.:extension&quot;
</pre>
<p>Also, when  you set up the database your model will need to have the following columns for Paperclip to work properly</p>
<pre class="wp-code-highlight prettyprint">
      t.column :avatar_file_name, :string
      t.column :avatar_content_type, :string
      t.column :avatar_file_size, :integer
</pre>
<p>Don&#8217;t forget that to handle file uploads in Rails you need to set the form with</p>
<pre class="wp-code-highlight prettyprint">
form_for current_user, :html =&gt;{:multipart =&gt; true} do |f|
</pre>
<p>Otherwise, your upload won&#8217;t work :(</p>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/ruby-on-rails/rails-paperclip-plugin-options-for-attaching-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Build Your Own Calendar in Rails without any Plugins in less than 10 lines of Ruby Code</title>
		<link>http://seanbehan.com/ruby-on-rails/build-your-own-calendar-in-rails-without-any-plugins-in-less-than-10-lines-of-ruby-code/</link>
		<comments>http://seanbehan.com/ruby-on-rails/build-your-own-calendar-in-rails-without-any-plugins-in-less-than-10-lines-of-ruby-code/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 17:08:12 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[calendar]]></category>
		<category><![CDATA[erb]]></category>
		<category><![CDATA[haml]]></category>
		<category><![CDATA[plugins]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=553</guid>
		<description><![CDATA[There are a number of terrific calendar plugins for Rails. But it&#8217;s almost as easy, if not easier, to implement your own calendar. The steps are pretty simple. First get the @beginning_of_month and @end_of_month and iterate over the days in between. In the loop we check if the day matches the @beginning_of_month and if it [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fruby-on-rails%2Fbuild-your-own-calendar-in-rails-without-any-plugins-in-less-than-10-lines-of-ruby-code%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Build Your Own Calendar in Rails without any Plugins in less than 10 lines of Ruby Code" data-url="http://seanbehan.com/ruby-on-rails/build-your-own-calendar-in-rails-without-any-plugins-in-less-than-10-lines-of-ruby-code/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>There are a number of terrific calendar plugins for Rails. But it&#8217;s almost as easy, if not easier, to implement your own calendar.</p>
<p>The steps are pretty simple. First get the @beginning_of_month and @end_of_month and iterate over the days in between. In the loop we check if the day matches the @beginning_of_month and if it does we get the offset ( 0 &#8211; 6 ) because if the month doesn&#8217;t start on a Sunday all our days won&#8217;t match up correctly. We print out the offset number as table cells &lt;td class=&#8217;offset&#8217;&gt;&lt;/td&gt;. We then need to consider that weeks &#8216;restart&#8217; and restart our row if we&#8217;re at the beginning of the week&#8230; this is accomplished with &lt;/tr&gt;&lt;tr&gt;. Then we just output the date contained in table cells &lt;td&gt;#{d.day}&lt;/td&gt;.  The code is below and it&#8217;s pretty simple.</p>
<p>In this example I use haml, but you could just as easily use ERB (at the bottom). If you&#8217;re not familiar with haml, check it out at http://haml-lang.com/ Haml automatically handles wrapping your html so you don&#8217;t have to! The end result is that it cuts your html in half and makes it look pretty, which in turns makes it a lot more manageable long term.</p>
<p>#app/views/calendars/show.html.haml</p>
<pre class="wp-code-highlight prettyprint">%table#calendar
  %tr
    %th
      Sunday
    %th
      Monday
    %th
      Tuesday
    %th
      Wednesday
    %th
      Thursday
    %th
      Friday
    %th
      Saturday
  %tr
    - @beginning_of_month = Date.civil(2009,12,1)
    - @end_of_month       = Date.civil(2009, 12, -1)

    - (@beginning_of_month..@end_of_month).each do |d|
      - if d == @beginning_of_month
        - (d.wday).times do # offset beginning of calendar
         &amp;lt; td class='offset'&amp;gt; &amp;lt;/td&amp;gt;
      -if d.wday == 0 #restart the week
        &amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;

      == &amp;lt;td class='#{d}'&amp;gt; #{d.day} &amp;lt;/td&amp;gt;</pre>
<p>Here it is in ERB</p>
<pre class="wp-code-highlight prettyprint">&amp;lt;&lt;span&gt;table&lt;/span&gt;&lt;span&gt; id&lt;/span&gt;=&lt;span&gt;'calendar'&lt;/span&gt;&amp;gt;
 &amp;lt;&lt;span&gt;tr&lt;/span&gt;&amp;gt;
   &amp;lt;&lt;span&gt;th&lt;/span&gt;&amp;gt;Sunday&amp;lt;/&lt;span&gt;th&lt;/span&gt;&amp;gt;&amp;lt;&lt;span&gt;th&lt;/span&gt;&amp;gt;Monday&amp;lt;/&lt;span&gt;th&lt;/span&gt;&amp;gt;
   &amp;lt;&lt;span&gt;th&lt;/span&gt;&amp;gt;Tuesday&amp;lt;/&lt;span&gt;th&lt;/span&gt;&amp;gt;&amp;lt;&lt;span&gt;th&lt;/span&gt;&amp;gt;Wednesday&amp;lt;/&lt;span&gt;th&lt;/span&gt;&amp;gt;
   &amp;lt;&lt;span&gt;th&lt;/span&gt;&amp;gt;Thursday&amp;lt;/&lt;span&gt;th&lt;/span&gt;&amp;gt;&amp;lt;&lt;span&gt;th&lt;/span&gt;&amp;gt;Friday&amp;lt;/&lt;span&gt;th&lt;/span&gt;&amp;gt;
   &amp;lt;&lt;span&gt;th&lt;/span&gt;&amp;gt;Saturday&amp;lt;/&lt;span&gt;th&lt;/span&gt;&amp;gt;
  &amp;lt;/&lt;span&gt;tr&lt;/span&gt;&amp;gt;
  &amp;lt;&lt;span&gt;tr&lt;/span&gt;&amp;gt;
  &amp;lt;% @beginning_of_month = Date.civil(2009, 12, 1) %&amp;gt;
  &amp;lt;% @end_of_month = Date.civil(2009, 12, -1) %&amp;gt;

  &amp;lt;% (@beginning_of_month..@end_of_month).each do |d| %&amp;gt;
    &amp;lt;% if d == @beginning_of_month %&amp;gt;
      &amp;lt;% d.wday.times do %&amp;gt; &amp;lt;td class='offset'&amp;gt;&amp;lt;/td&amp;gt; &amp;lt;% end %&amp;gt;
    &amp;lt;% end %&amp;gt;

    &amp;lt;% if d.wday == 0 %&amp;gt; &amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt; &amp;lt;% end %&amp;gt;
    &amp;lt;td&amp;gt; &amp;lt;%= d.day %&amp;gt; &amp;lt;/td&amp;gt;
  &amp;lt;% end %&amp;gt;
  &amp;lt;/tr&amp;gt;
&amp;lt;/table&amp;gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/ruby-on-rails/build-your-own-calendar-in-rails-without-any-plugins-in-less-than-10-lines-of-ruby-code/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Acts_as_versioned Rails Plugin</title>
		<link>http://seanbehan.com/ruby-on-rails/acts_as_versioned-rails-plugin/</link>
		<comments>http://seanbehan.com/ruby-on-rails/acts_as_versioned-rails-plugin/#comments</comments>
		<pubDate>Thu, 17 Sep 2009 16:14:26 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[active record]]></category>
		<category><![CDATA[plugins]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=535</guid>
		<description><![CDATA[Versioning models with the acts_as_versioned plugin cd rails/app ./script/plugin install git://github.com/technoweenie/acts_as_versioned.git ./script/generate model post title:string body:text In your model class Post &#60; ActiveRecord::Base acts_as_versioned end In db/migrate/****_create_posts.rb def self.up create_table :posts do &#124;t&#124; t.string :title t.text :body t.timestamps end Post.create_versioned_table end def self.down drop_table :posts Post.drop_versioned_table end Migrate your db rake db:migrate Usage p = [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fruby-on-rails%2Facts_as_versioned-rails-plugin%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Acts_as_versioned Rails Plugin" data-url="http://seanbehan.com/ruby-on-rails/acts_as_versioned-rails-plugin/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>Versioning models with the acts_as_versioned plugin</p>
<pre class="wp-code-highlight prettyprint">
cd rails/app
./script/plugin install git://github.com/technoweenie/acts_as_versioned.git
./script/generate model post title:string body:text
</pre>
<p>In your model</p>
<pre class="wp-code-highlight prettyprint">
class Post &lt; ActiveRecord::Base
  acts_as_versioned
end
</pre>
<p>In db/migrate/****_create_posts.rb</p>
<pre class="wp-code-highlight prettyprint">
  def self.up
    create_table :posts do |t|
      t.string :title
      t.text :body
      t.timestamps
    end
    Post.create_versioned_table
  end

  def self.down
    drop_table :posts
    Post.drop_versioned_table
  end
</pre>
<p>Migrate your db</p>
<pre class="wp-code-highlight prettyprint">
rake db:migrate
</pre>
<p>Usage</p>
<pre class="wp-code-highlight prettyprint">
p = Post.create :body =&gt; &quot;hello world&quot;
p.body = &quot;HELLO WORLD&quot;
p.save

p.versions.size
p.versions.last
p.revert_to(p.versions.first)
p.body # =&gt; hello world
</pre>
<p><em>*Quick Note</em> If you want to revert to an older version in a controller or something, don&#8217;t do</p>
<pre class="wp-code-highlight prettyprint">@post = @post.revert_to(2)</pre>
<p> Revert_to method will return a TrueClass, Boolean type. Instead use</p>
<pre class="wp-code-highlight prettyprint">@post.revert_to(2)</pre>
<p> This method will update the attributes for you and when you call them you&#8217;ll get that version.</p>
<p>More information is available here http://ar-versioned.rubyforge.org/ and http://www.urbanhonking.com/ideasfordozens/archives/2006/02/learns_to_use_a_1.html</p>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/ruby-on-rails/acts_as_versioned-rails-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>using rails paperclip plugin on ubuntu</title>
		<link>http://seanbehan.com/programming/using-rails-paperclip-plugin-on-ubuntu/</link>
		<comments>http://seanbehan.com/programming/using-rails-paperclip-plugin-on-ubuntu/#comments</comments>
		<pubDate>Fri, 13 Mar 2009 20:19:19 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[libs]]></category>
		<category><![CDATA[plugins]]></category>

		<guid isPermaLink="false">http://bseanvt.wordpress.com/?p=27</guid>
		<description><![CDATA[paperclip is an awesome plugin for rails. it let&#8217;s you attach an image to any of your models. installation and usage more information is available at http://jimneath.org/2008/04/17/paperclip-attaching-files-in-rails/ by default paperclip uses the image magick library for image manipulation/resizing. you&#8217;ll need to install this library as well as the ruby api to it in order to [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fprogramming%2Fusing-rails-paperclip-plugin-on-ubuntu%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="using rails paperclip plugin on ubuntu" data-url="http://seanbehan.com/programming/using-rails-paperclip-plugin-on-ubuntu/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>paperclip is an awesome plugin for rails. it let&#8217;s you attach an image to any of your models. installation and usage more information is available at http://jimneath.org/2008/04/17/paperclip-attaching-files-in-rails/</p>
<p>by default paperclip uses the image magick library for image manipulation/resizing. you&#8217;ll need to install this library as well as the ruby api to it in order to use it. on ubuntu using apt get here are the commands</p>
<pre class="wp-code-highlight prettyprint">
apt-get install imagemagick
apt-get install librmagick-ruby1.8
</pre>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/programming/using-rails-paperclip-plugin-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

