<?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>Simone Carletti&#039;s Blog &#187; plugins</title>
	<atom:link href="http://www.simonecarletti.com/blog/tags/plugins/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.simonecarletti.com/blog</link>
	<description>Simone Carletti&#039;s personal ramblings on programming, syndication, search engines &#38; marketing.</description>
	<lastBuildDate>Thu, 12 Jan 2012 09:16:49 +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>BreadcrumbOnRails now open-source</title>
		<link>http://www.simonecarletti.com/blog/2009/11/breadcrumbonrails/</link>
		<comments>http://www.simonecarletti.com/blog/2009/11/breadcrumbonrails/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 21:07:30 +0000</pubDate>
		<dc:creator>Simone Carletti</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[breadcrumbs]]></category>
		<category><![CDATA[breadcrumbs on rails]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.simonecarletti.com/blog/?p=744</guid>
		<description><![CDATA[BreadcrumbsOnRails is a simple Ruby on Rails plugin for creating and managing a breadcrumb navigation for a Rails project.]]></description>
			<content:encoded><![CDATA[<p>A few months ago I created <strong>BreadcrumbsOnRails</strong> to solve the recurrent pattern of <strong>creating breadcrumb navigations with Ruby on Rails</strong>. Today I&#8217;m open-sourcing <a href="http://code.simonecarletti.com/breadcrumbsonrails">the project</a> and the code is now <a href="http://github.com/weppos/breadcrumbs_on_rails">available on GitHub</a>.</p>
<p>BreadcrumbsOnRails is a simple Ruby on Rails plugin for creating and managing a breadcrumb navigation for a Rails project. It provides helpers for creating navigation elements with a flexible interface.<span id="more-744"></span></p>
<p>You can install BreadcrumbsOnRails as a Gem</p>
<div class="codecolorer-container text default code-bash" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ gem install breadcrumbs_on_rails --source http://gemcutter.org</div></td></tr></tbody></table></div>
<div class="codecolorer-container text default brush: ruby;" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Rails::Initializer.run do |config|<br />
<br />
&nbsp; # other configurations<br />
&nbsp; # ...<br />
<br />
&nbsp; config.gem &quot;breadcrumbs_on_rails&quot;, :source =&gt; &quot;http://gemcutter.org&quot;<br />
<br />
end</div></td></tr></tbody></table></div>
<p>or as a Rails plugin</p>
<div class="codecolorer-container text default code-bash" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ script/plugin install git://github.com/weppos/breadcrumbs_on_rails.git</div></td></tr></tbody></table></div>
<h2>Usage</h2>
<p>Creating a breadcrumb navigation menu in your Rails app using BreadcrumbsOnRails is really straightforward.</p>
<p>In your controller, call <code>add_breadcrumb</code> to push a new element on the breadcrumb stack. <code>add_breadcrumb</code> requires two arguments: the name of the breadcrumb and the target path.</p>
<div class="codecolorer-container text default code-ruby" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">class MyController<br />
<br />
&nbsp; add_breadcrumb &quot;home&quot;, root_path<br />
&nbsp; add_breadcrumb &quot;my&quot;, my_path<br />
<br />
&nbsp; def index<br />
&nbsp; &nbsp; # ...<br />
<br />
&nbsp; &nbsp; add_breadcrumb &quot;index&quot;, index_path<br />
&nbsp; end<br />
<br />
end</div></td></tr></tbody></table></div>
<p>In your view, you can render the breadcrumb menu with the <code>render_breadcrumbs</code> helper.</p>
<div class="codecolorer-container text default code-ruby" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;!--&lt;span class=&quot;hiddenSpellError&quot; pre=&quot;&quot;--&gt;DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;<br />
&nbsp;&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;<br />
xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;en&quot; lang=&quot;en&quot;&gt;<br />
&lt;head&gt;<br />
&nbsp;&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;/&gt;<br />
&nbsp;&lt;title&gt;untitled&lt;/title&gt;<br />
&lt;/head&gt;<br />
<br />
&lt;body&gt;<br />
&nbsp;&lt;%= render_breadcrumbs %&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</div></td></tr></tbody></table></div>
<p><code>render_breadcrumbs</code> understands a limited set of options. For example, you can pass change the default separator with the <code>:separator</code> option.</p>
<div class="codecolorer-container text default code-ruby" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;body&gt;<br />
&nbsp;&lt;%= render_breadcrumbs :separator =&gt; ' / ' %&gt;<br />
&lt;/body&gt;</div></td></tr></tbody></table></div>
<p>More complex customizations require a custom Builder.</p>
<h3>Breadcrumb Element</h3>
<p>A breadcrumbs menu is composed by a number of <code>Element</code> objects. Each object contains two attributes: the name of the breadcrumb and the target path.</p>
<p>When you call <code>add_breadcrumb</code>, the method automatically creates a new <code>Element</code> object for you and append it to the breadcrumbs stack. <code>Element</code> name and path can be one of the following Ruby types:</p>
<ul>
<li>Symbol</li>
<li>Proc</li>
<li>String</li>
</ul>
<h4>Symbol</h4>
<p>If the value is a Symbol, the library calls the corresponding method defined in the same context the and sets the <code>Element</code> attribute to the returned value.</p>
<div class="codecolorer-container text default code-ruby" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">class MyController<br />
<br />
&nbsp; # The Name is set to the value returned by<br />
&nbsp; # the :root_name method.<br />
&nbsp; add_breadcrumb :root_name, root_path<br />
<br />
&nbsp; protected<br />
<br />
&nbsp; &nbsp; def root_name<br />
&nbsp; &nbsp; &nbsp; &quot;the name&quot;<br />
&nbsp; &nbsp; end<br />
<br />
end</div></td></tr></tbody></table></div>
<h4>Proc</h4>
<p>If the value is a Proc, the library calls the proc passing the current view context as argument and sets the <code>Element</code> attribute to the returned value. This is useful if you want to postpone the execution to get access to some special methods/variables created in your controller action.</p>
<div class="codecolorer-container text default code-ruby" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">class MyController<br />
<br />
&nbsp; # The Name is set to the value returned by<br />
&nbsp; # the :root_name method.<br />
&nbsp; add_breadcrumb Proc.new { |c| c.my_helper_method },<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;root_path<br />
<br />
end</div></td></tr></tbody></table></div>
<h4>String</h4>
<p>If the value is a Proc, the library sets the <code>Element</code> attribute to the string value.</p>
<div class="codecolorer-container text default code-ruby" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">class MyController<br />
<br />
&nbsp; # The Name is set to the value returned by<br />
&nbsp; # the :root_name method.<br />
&nbsp; add_breadcrumb &quot;homepage&quot;, &quot;http://example.com/&quot;<br />
<br />
end</div></td></tr></tbody></table></div>
<h3>Restricting breadcrum scope</h3>
<p>The <code>add_breadcrumb</code> method understands all options you are used to pass to a Rails controller filter.<br />
In fact, behind the scenes this method uses a <code>before_filter</code> to store the tab in the <code>@breadcrumbs</code> variable.</p>
<p>Taking advantage of Rails filter options, you can restrict a tab to a selected group of actions in the same controller.</p>
<div class="codecolorer-container text default code-ruby" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">class PostsController &lt; ApplicationController<br />
&nbsp; add_breadcrumb &quot;admin&quot;, admin_path<br />
&nbsp; add_breadcrumb &quot;posts, posts_path, :only =&gt; %w(index show)<br />
end<br />
<br />
class ApplicationController &lt; ActionController::Base<br />
&nbsp; add_breadcrumb &quot;admin&quot;, admin_path, :if =&gt; :admin_controller?<br />
<br />
&nbsp; def admin_controller?<br />
&nbsp; &nbsp; self.class.name =~ /^Admin(::|Controller)/<br />
&nbsp; end<br />
end</div></td></tr></tbody></table></div>
<h3>Internationalization and Localization</h3>
<p>BreadcrumbsOnRails is compatible with the standard Rails internationalization framework.</p>
<p>For example, if you want to localize your menu, define a new breadcrumbs node in your .yml file with all the keys for your elements.</p>
<div class="codecolorer-container text default brush: yaml" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"># config/locales/en.yml<br />
en:<br />
&nbsp; breadcrumbs:<br />
&nbsp; &nbsp; homepage: Homepage<br />
&nbsp; &nbsp; first: First<br />
&nbsp; &nbsp; second: Second<br />
&nbsp; &nbsp; third: Third<br />
<br />
# config/locales/it.yml<br />
it:<br />
&nbsp; breadcrumbs:<br />
&nbsp; &nbsp; homepage: Homepage<br />
&nbsp; &nbsp; first: Primo<br />
&nbsp; &nbsp; second: Secondo<br />
&nbsp; &nbsp; third: Terzo</div></td></tr></tbody></table></div>
<p>In your controller, use the <code>I18n.t</code> method.</p>
<div class="codecolorer-container text default code-ruby" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">class PostsController &lt; ApplicationController &nbsp; add_breadcrumb I18n.t(&quot;breadcrumbs.first&quot;), first_path &nbsp; add_breadcrumb I18n.t(&quot;breadcrumbs.second&quot;), second_path, :only =&gt; %w(second)<br />
&nbsp; add_breadcrumb I18n.t(&quot;breadcrumbs.third&quot;), third_path, :only =&gt; %w(third)<br />
end<br />
<br />
class ApplicationController &lt; ActionController::Base<br />
&nbsp; add_breadcrumb I18n.t(&quot;breadcrumbs.homepage&quot;), root_path<br />
end</div></td></tr></tbody></table></div>
<h2>Resources</h2>
<p>BreadcrumbsOnRails is released under the terms of the MIT License. The source code is <a href="http://github.com/weppos/breadcrumbs_on_rails">available on GitHub</a>.</p>
<p>BreadcrumbsOnRails is not suitable for a generic navigation menu. If you are looking for a way to create a generic or a tabbed navigation menu, check out my <a href="http://www.simonecarletti.com/blog/2009/04/tabsonrails/">TabsOnRails plugin</a>.</p>
<p>Related posts<ol>
<li><a href='http://www.simonecarletti.com/blog/2009/09/inside-ruby-on-rails-reading-source-code/' rel='bookmark' title='Understanding Ruby and Rails: Reading Source Code'>Understanding Ruby and Rails: Reading Source Code</a></li>
<li><a href='http://www.simonecarletti.com/blog/2009/08/ruby-on-rails-and-canonical-link-tag/' rel='bookmark' title='Ruby on Rails and Canonical link tag'>Ruby on Rails and Canonical link tag</a></li>
<li><a href='http://www.simonecarletti.com/blog/2009/03/helperful-030/' rel='bookmark' title='Helperful 0.3.0'>Helperful 0.3.0</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.simonecarletti.com/blog/2009/11/breadcrumbonrails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TabsOnRails 0.3.0 with concurrent tabs support aka namespaces</title>
		<link>http://www.simonecarletti.com/blog/2009/05/tabsonrails-030-with-concurrent-tabs-support-aka-namespaces/</link>
		<comments>http://www.simonecarletti.com/blog/2009/05/tabsonrails-030-with-concurrent-tabs-support-aka-namespaces/#comments</comments>
		<pubDate>Sat, 02 May 2009 12:35:31 +0000</pubDate>
		<dc:creator>Simone Carletti</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[tabs]]></category>
		<category><![CDATA[tabs on rails]]></category>

		<guid isPermaLink="false">http://www.simonecarletti.com/blog/?p=323</guid>
		<description><![CDATA[TabsOnRails is a simple Rails plugin for creating and managing Tabs. The release 0.3.0 is now available as a GEM, with multi-tabs support.]]></description>
			<content:encoded><![CDATA[<p><strong><a href="http://www.simonecarletti.com/code/tabs_on_rails">TabsOnRails</a></strong> is a simple Rails plugin for <strong>creating and managing Tabs in Rails projects</strong>. It provides helpers for creating tabs with a flexible interface.</p>
<p>The release 0.3.0 is now available as a GEM. The most important feature is the concurrent tabs support, also known as multi-tabs or namespaces. Namespaces enable you to create and manage tabs in parallels. Let me show you an example.<span id="more-323"></span></p>
<p>Let&#8217;s assume your application provides a first level navigation menu with 3 elements: <code>:home</code>, <code>:dashboard</code>, <code>:projects</code>. The relationship between your tabs and your controllers is 1:1 so you should end up with the following source code.</p>
<div class="codecolorer-container text default code-ruby" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">class HomeController<br />
&nbsp; set_tab :home<br />
end<br />
<br />
class DashboardController<br />
&nbsp; set_tab :dashboard<br />
end<br />
<br />
class ProjectsController<br />
&nbsp; set_tab :projects<br />
<br />
&nbsp; def first; end<br />
&nbsp; def second; end<br />
&nbsp; def third; end<br />
end</div></td></tr></tbody></table></div>
<p>The project controller contains 3 actions and you might want to create a second-level navigation menu. This menu should reflect the navigation status of the user in the project page.</p>
<p>Without namespaces, you wouldn&#8217;t be able to accomplish this task because you already set the current tab value to <code>:projects</code>. You need to create a concurrent navigation menu and uniquely identify it with a custom namespace.<br />
Let&#8217;s call it <code>:navigation</code>.</p>
<div class="codecolorer-container text default code-ruby" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">class ProjectsController<br />
&nbsp; set_tab :projects<br />
<br />
&nbsp; # Create an other tab navigation level<br />
&nbsp; set_tab :first, :navigation, :only =&gt; %w(first)<br />
&nbsp; set_tab :second, :navigation, :only =&gt; %w(second)<br />
&nbsp; set_tab :third, :navigation, :only =&gt; %w(third)<br />
<br />
&nbsp; def first; end<br />
&nbsp; def second; end<br />
&nbsp; def third; end<br />
end</div></td></tr></tbody></table></div>
<p>Voilà! That&#8217;s all you need to do. And you can create an unlimited number of namespace as long as you use an unique name to identify them.</p>
<p>The default namespace is called :default. Passing :default as name is the same as don&#8217;t using any namespace at all. The following lines are equivalent.</p>
<div class="codecolorer-container text default code-ruby" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">set_tab :projects<br />
set_tab :projects, :default</div></td></tr></tbody></table></div>
<p>Namespaces supports all the other features already available in <strong>TabsOnRails</strong> including custom Builders for your Rails tabs. See the <a href="http://www.simonecarletti.com/code/tabs_on_rails/docs.html">documentation page</a> for further information.</p>
<p>You can install/upgrade <strong>TabsOnRails</strong> by running</p>
<div class="codecolorer-container text default code-ruby" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ sudo gem install weppos-tabs_on_rails --source http://gems.github.com</div></td></tr></tbody></table></div>
<p>Related posts<ol>
<li><a href='http://www.simonecarletti.com/blog/2009/04/tabsonrails/' rel='bookmark' title='TabsOnRails: creating and managing Tabs with Ruby on Rails'>TabsOnRails: creating and managing Tabs with Ruby on Rails</a></li>
<li><a href='http://www.simonecarletti.com/blog/2009/10/tabsonrails-graduated-from-beta/' rel='bookmark' title='TabsOnRails graduated from beta'>TabsOnRails graduated from beta</a></li>
<li><a href='http://www.simonecarletti.com/blog/2009/06/tabsonrails-0-8-0/' rel='bookmark' title='TabsOnRails 0.8.0'>TabsOnRails 0.8.0</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.simonecarletti.com/blog/2009/05/tabsonrails-030-with-concurrent-tabs-support-aka-namespaces/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>ActiveRecord::MultiConditions development discontinued</title>
		<link>http://www.simonecarletti.com/blog/2009/04/activerecordmulticonditions-development-discontinued/</link>
		<comments>http://www.simonecarletti.com/blog/2009/04/activerecordmulticonditions-development-discontinued/#comments</comments>
		<pubDate>Sun, 26 Apr 2009 19:55:49 +0000</pubDate>
		<dc:creator>Simone Carletti</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[activerecord-multiconditions]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.simonecarletti.com/blog/?p=287</guid>
		<description><![CDATA[As of April 2009, I decided to discontinue the development of ActiveRecord::MultiConditions to concentrate my efforts on other projects.]]></description>
			<content:encoded><![CDATA[<p>As of April 2009, I decided to discontinue the development of <a href="http://code.simonecarletti.com/multiconditions">ActiveRecord::MultiConditions</a> to concentrate my efforts on <a href="http://www.simonecarletti.com/code/tabs_on_rails">other projects</a>.</p>
<p>If you are looking for a good alternative, I encourage you to have a look at Ben Johnson&#8217;s <a class="external" href="http://searchlogic.rubyforge.org/">Searchlogic</a> library. SearchLogic provides all ActiveRecord::Multiconditions features along with many other cool stuff.</p>
<p>There are many other projects that needs my assistance at the moment. I&#8217;m planning to release a new version of <a href="http://www.simonecarletti.com/code/tabs_on_rails">Tabs On Rails</a> with multiple tabs support, the <a href="http://code.simonecarletti.com/gaonrails">Google Analytics on Rails</a> plugin needs to be completed and I&#8217;m working on a couple of Rails products. I definitely want to make a private beta version of <a href="http://www.getlinkto.com/">GetLinkTo</a> available in a couple of months.</p>
<p>Related posts<ol>
<li><a href='http://www.simonecarletti.com/blog/2009/05/tabsonrails-030-with-concurrent-tabs-support-aka-namespaces/' rel='bookmark' title='TabsOnRails 0.3.0 with concurrent tabs support aka namespaces'>TabsOnRails 0.3.0 with concurrent tabs support aka namespaces</a></li>
<li><a href='http://www.simonecarletti.com/blog/2009/06/tabsonrails-0-8-0/' rel='bookmark' title='TabsOnRails 0.8.0'>TabsOnRails 0.8.0</a></li>
<li><a href='http://www.simonecarletti.com/blog/2009/06/how-to-test-rails-activerecord-named-scopes/' rel='bookmark' title='Testing Rails: How to test Rails ActiveRecord Named Scopes'>Testing Rails: How to test Rails ActiveRecord Named Scopes</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.simonecarletti.com/blog/2009/04/activerecordmulticonditions-development-discontinued/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TabsOnRails: creating and managing Tabs with Ruby on Rails</title>
		<link>http://www.simonecarletti.com/blog/2009/04/tabsonrails/</link>
		<comments>http://www.simonecarletti.com/blog/2009/04/tabsonrails/#comments</comments>
		<pubDate>Sat, 25 Apr 2009 14:42:48 +0000</pubDate>
		<dc:creator>Simone Carletti</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[tabs]]></category>
		<category><![CDATA[tabs on rails]]></category>

		<guid isPermaLink="false">http://www.simonecarletti.com/blog/?p=297</guid>
		<description><![CDATA[TabsOnRails is a simple Rails plugin for creating and managing Tabs. It provides helpers for creating tabs with a flexible interface.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.simonecarletti.com/code/tabs_on_rails"><em>TabsOnRails</em></a> is a simple Rails plugin for <strong>creating and managing Tabs</strong>. It provides helpers for creating tabs with a flexible interface.</p>
<p>If you ever had to create a tab-based navigation menu at least once, you perfectly know how much it can annoying. You have to create the menu, set active status in your controllers and reflect selection status in your view. <em>TabsOnRails</em> does all the boring stuff for you and let you focus on the customization.</p>
<p>Let me show you how it works.<span id="more-297"></span></p>
<h2>Quick Start</h2>
<p>In your template use the <code>tabs_tag</code> helper to create your tab.</p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#006600; font-weight:bold;">&lt;%</span>= tabs_tag <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>tab<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#006600; font-weight:bold;">%&gt;</span><br />
&nbsp; <span style="color:#006600; font-weight:bold;">&lt;%</span>= tab.<span style="color:#9900CC;">home</span> &nbsp; &nbsp; &nbsp; <span style="color:#996600;">'Homepage'</span>, root_path <span style="color:#006600; font-weight:bold;">%&gt;</span><br />
&nbsp; <span style="color:#006600; font-weight:bold;">&lt;%</span>= tab.<span style="color:#9900CC;">dashboard</span> &nbsp;<span style="color:#996600;">'Dashboard'</span>, dashboard_path <span style="color:#006600; font-weight:bold;">%&gt;</span><br />
&nbsp; <span style="color:#006600; font-weight:bold;">&lt;%</span>= tab.<span style="color:#9900CC;">account</span> &nbsp; &nbsp;<span style="color:#996600;">'Account'</span>, account_path <span style="color:#006600; font-weight:bold;">%&gt;</span><br />
<span style="color:#006600; font-weight:bold;">&lt;%</span> <span style="color:#9966CC; font-weight:bold;">end</span> <span style="color:#006600; font-weight:bold;">%&gt;</span></div></td></tr></tbody></table></div>
<p>The example above produces the following HTML output.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/ul.html"><span style="color: #000000; font-weight: bold;">ul</span></a>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">li</span></a>&gt;&lt;<a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;/&quot;</span>&gt;</span>Homepage<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">li</span></a>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">li</span></a>&gt;&lt;<a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;/dashboard&quot;</span>&gt;</span>Dashboard<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">li</span></a>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">li</span></a>&gt;&lt;<a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;/account&quot;</span>&gt;</span>Account<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">li</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/ul.html"><span style="color: #000000; font-weight: bold;">ul</span></a>&gt;</span></div></td></tr></tbody></table></div>
<p>The usage is similar to the Rails <code>route.rb</code> file. You create named tabs with the syntax <code>tab.name_of_tab</code>. The name you use creating a tab is the same you&#8217;re going to refer to in your controller when you want to flag the tab as active with <code>current_tab</code>.</p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#9966CC; font-weight:bold;">class</span> DashboardController <span style="color:#006600; font-weight:bold;">&lt;</span> ApplicationController<br />
&nbsp; current_tab <span style="color:#ff3333; font-weight:bold;">:dashboard</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></td></tr></tbody></table></div>
<p>Now, for any action defined in the <code>DashboardController</code>, the template will automatically render the following HTML code.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/ul.html"><span style="color: #000000; font-weight: bold;">ul</span></a>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">li</span></a>&gt;&lt;<a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;/&quot;</span>&gt;</span>Homepage<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">li</span></a>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">li</span></a>&gt;&lt;<a href="http://december.com/html/4/element/span.html"><span style="color: #000000; font-weight: bold;">span</span></a>&gt;</span>Dashboard<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/span.html"><span style="color: #000000; font-weight: bold;">span</span></a>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">li</span></a>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">li</span></a>&gt;&lt;<a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;/account&quot;</span>&gt;</span>Account<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">li</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/ul.html"><span style="color: #000000; font-weight: bold;">ul</span></a>&gt;</span></div></td></tr></tbody></table></div>
<h2>Restricting current_tab scope</h2>
<p>Off course, there are specific situations where you need to change current_tag only for some specific action in your controller.</p>
<p>The <code>current_tab</code> method understands all options you are used to pass to a Rails controller filter. In fact, behind the scenes this method uses a <code>before_filter</code> to set a special <code>@current_tab</code> variable. Taking advantage of Rails filter options, you can restrict a tab to a selected group of actions in the same controller.</p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#9966CC; font-weight:bold;">class</span> PostsController <span style="color:#006600; font-weight:bold;">&lt;</span> ApplicationController<br />
&nbsp; current_tab <span style="color:#ff3333; font-weight:bold;">:admin</span><br />
&nbsp; current_tab <span style="color:#ff3333; font-weight:bold;">:posts</span>, <span style="color:#ff3333; font-weight:bold;">:only</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span> <span style="color:#ff3333; font-weight:bold;">:index</span>, <span style="color:#ff3333; font-weight:bold;">:show</span> <span style="color:#006600; font-weight:bold;">&#93;</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
<span style="color:#9966CC; font-weight:bold;">class</span> ApplicationController <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActionController::Base</span><br />
&nbsp; current_tab <span style="color:#ff3333; font-weight:bold;">:admin</span>, :<span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:admin_controller</span>?<br />
<br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> admin_controller?<br />
&nbsp; &nbsp; <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9966CC; font-weight:bold;">class</span>.<span style="color:#9900CC;">name</span> =~ <span style="color:#006600; font-weight:bold;">/</span>^Admin<span style="color:#006600; font-weight:bold;">&#40;</span>::<span style="color:#006600; font-weight:bold;">|</span>Controller<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">/</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></td></tr></tbody></table></div>
<h2>Customizations</h2>
<p>All your tabs belongs to you! Easily to understand, your tab structure might be slightly different that the default one. For example, you might want to flag the active tab with a <code>current</code> CSS class and preserve the link with a nice hover effect. Or perhaps your tab is an ordered list (&lt;ol&gt;).</p>
<p>No problem! The library is completely customizable using custom builders. See the documentation for further details on <a href="http://www.simonecarletti.com/code/tabs_on_rails/docs.html">how to create and use a custom Tab Builder</a>.</p>
<p>Here&#8217;s just a couple of examples created using custom builders.</p>
<p><img class="aligncenter size-medium wp-image-303" title="tab-example11" src="http://www.simonecarletti.com/blog/wp-content/uploads/2009/04/tab-example11-400x118.png" alt="tab-example11" width="400" height="118" /></p>
<h2><img class="aligncenter size-medium wp-image-302" title="tab-example2" src="http://www.simonecarletti.com/blog/wp-content/uploads/2009/04/tab-example2-400x215.png" alt="tab-example2" width="400" height="215" /></h2>
<h2>Cool! How do I get the plugin?</h2>
<p>Source code and issue management is <a href="http://github.com/weppos/tabs_on_rails/">powered by GitHub</a>, the project homepage and documentation are hosted on <a href="http://www.simonecarletti.com/code/tabs_on_rails">this site</a>. The plugin is available both as a GEM and as a Rails plugin. See the <a href="http://www.simonecarletti.com/code/tabs_on_rails/docs.html">documentation page</a> to learn how to install it.</p>
<p>Related posts<ol>
<li><a href='http://www.simonecarletti.com/blog/2009/05/tabsonrails-030-with-concurrent-tabs-support-aka-namespaces/' rel='bookmark' title='TabsOnRails 0.3.0 with concurrent tabs support aka namespaces'>TabsOnRails 0.3.0 with concurrent tabs support aka namespaces</a></li>
<li><a href='http://www.simonecarletti.com/blog/2009/10/tabsonrails-graduated-from-beta/' rel='bookmark' title='TabsOnRails graduated from beta'>TabsOnRails graduated from beta</a></li>
<li><a href='http://www.simonecarletti.com/blog/2009/06/tabsonrails-0-8-0/' rel='bookmark' title='TabsOnRails 0.8.0'>TabsOnRails 0.8.0</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.simonecarletti.com/blog/2009/04/tabsonrails/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>Helperful 0.3.0</title>
		<link>http://www.simonecarletti.com/blog/2009/03/helperful-030/</link>
		<comments>http://www.simonecarletti.com/blog/2009/03/helperful-030/#comments</comments>
		<pubDate>Mon, 16 Mar 2009 23:46:34 +0000</pubDate>
		<dc:creator>Simone Carletti</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[helperful]]></category>
		<category><![CDATA[helpers]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.simonecarletti.com/blog/?p=251</guid>
		<description><![CDATA[Available Helperful 0.3.0 with the new javascript_content_for helper.]]></description>
			<content:encoded><![CDATA[<p>Last week I released a new minor version of the <a href="http://www.simonecarletti.com/blog/2009/02/helperful-a-large-collection-of-rails-helpers/">Helperful GEM</a>. This is essentially a bugfix release, although it comes with one minor new feature: the <code>javascript_content_for</code> tag. The following overview is taken directly from the <a href="http://code.simonecarletti.com/wiki/helperful/JavascriptHelper">documentation</a>.</p>
<p>The <code>javascript_content_for</code> helper combines the features of content_for and javascript_tag into a single helper.</p>
<div class="codecolorer-container text default code-ruby" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;% javascript_content_for :head do %&gt;<br />
$(&quot;#id&quot;).hide();<br />
&lt;% end %&gt;</div></td></tr></tbody></table></div>
<p>The block is passed as it is to <code>javascript_tag</code>, then the result is stored as <code>content_for :head</code>.</p>
<p>Now you can call yield and output your javascript content.</p>
<div class="codecolorer-container text default code-ruby" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;%= yield :head %&gt;<br />
&lt;script&gt;$(&quot;#id&quot;).hide();&lt;/script&gt;</div></td></tr></tbody></table></div>
<p>This example is equal to the following statements.</p>
<div class="codecolorer-container text default code-ruby" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;% javascript_content_for :head do; javascript_tag do %&gt; $(&quot;#id&quot;).hide(); &lt;% end; end %&gt;<br />
&lt;% javascript_content_for :head do %&gt;<br />
&lt;script&gt;$(&quot;#id&quot;).hide();&lt;/script&gt;<br />
&lt;% end %&gt;</div></td></tr></tbody></table></div>
<p>This feature also addresses an annoying bug in the <code>has_content</code> helper method caused by an undefined variable.</p>
<p>To install or upgrade:</p>
<div class="codecolorer-container text default code-bash" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">gem install weppos-helperful --source http://gems.github.com</div></td></tr></tbody></table></div>
<p>More features still to come. Visit the <a href="http://code.simonecarletti.com/helperful">project page</a> for further details.</p>
<p>Related posts<ol>
<li><a href='http://www.simonecarletti.com/blog/2009/02/helperful-a-large-collection-of-rails-helpers/' rel='bookmark' title='Helperful: a large collection of Rails Helpers'>Helperful: a large collection of Rails Helpers</a></li>
<li><a href='http://www.simonecarletti.com/blog/2009/08/ruby-on-rails-and-canonical-link-tag/' rel='bookmark' title='Ruby on Rails and Canonical link tag'>Ruby on Rails and Canonical link tag</a></li>
<li><a href='http://www.simonecarletti.com/blog/2009/10/tabsonrails-and-helperful-migrated-to-gemcutter/' rel='bookmark' title='TabsOnRails and Helperful migrated to Gemcutter'>TabsOnRails and Helperful migrated to Gemcutter</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.simonecarletti.com/blog/2009/03/helperful-030/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Helperful: a large collection of Rails Helpers</title>
		<link>http://www.simonecarletti.com/blog/2009/02/helperful-a-large-collection-of-rails-helpers/</link>
		<comments>http://www.simonecarletti.com/blog/2009/02/helperful-a-large-collection-of-rails-helpers/#comments</comments>
		<pubDate>Thu, 26 Feb 2009 08:28:19 +0000</pubDate>
		<dc:creator>Simone Carletti</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[helperful]]></category>
		<category><![CDATA[helpers]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.simonecarletti.com/blog/?p=226</guid>
		<description><![CDATA[Helperful aims to be a collection of useful and reusable Rails helpers.]]></description>
			<content:encoded><![CDATA[<p><a href="http://code.simonecarletti.com/helperful">Helperful</a> aims to be a collection of useful and reusable Rails helpers.</p>
<h2>Rails Installation</h2>
<h3>As a Gem</h3>
<p>This is the preferred way to install Helperful and the best way if you want install a stable version.</p>
<div class="codecolorer-container text default brush: bash" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ gem install weppos-helperful --source http://gems.github.com&quot;</div></td></tr></tbody></table></div>
<p>You can specify the GEM dependency in your application environment.rb file:</p>
<div class="codecolorer-container text default code-ruby" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Rails::Initializer.run do |config|<br />
&nbsp; # other configurations<br />
&nbsp; # ...<br />
<br />
&nbsp; config.gem &quot;weppos-helperful&quot;, :lib =&gt; &quot;helperful&quot;, :source =&gt; &quot;http://gems.github.com&quot;<br />
end</div></td></tr></tbody></table></div>
<h3>As a Plugin</h3>
<p>This is the preferred way if you want to live on the edge and install a development version.</p>
<div class="codecolorer-container text default brush: bash" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ script/plugin install git://github.com/weppos/helperful.git</div></td></tr></tbody></table></div>
<p><span id="more-226"></span></p>
<h2>Available Helpers</h2>
<p>The list of available helpers actually includes <a href="http://code.simonecarletti.com/wiki/helperful/AffiliationsHelper">AffiliationsHelper</a>, <a href="http://code.simonecarletti.com/wiki/helperful/ContentHelper">ContentHelper</a> and the more famous <a href="http://code.simonecarletti.com/wiki/helperful/TitleHelper">TitleHelper</a>.</p>
<h3>Affiliations Helper</h3>
<p>Provides a set of helpers for working with online affiliations.</p>
<p>For example, the <code>tradedoubler_verification_tag</code> helper method returns the site verification tag required by Tradedoubler to verify the publisher account ownership.</p>
<div class="codecolorer-container text default code-ruby" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"># In your template<br />
&lt;%= tradedoubler_verification_tag('00112233') %&gt;<br />
<br />
# Will produce the following output.<br />
&lt;!-- TradeDoubler site verification 00112233 --&gt;</div></td></tr></tbody></table></div>
<h3>Content Helper</h3>
<p>Provides a set of helpers for capturing and working with your page content in a more effective way.</p>
<p>Fo example, the <code>has_content?</code> helper is a natural fulfillment for the original <code>content_for</code> helper.</p>
<div class="codecolorer-container text default code-ruby" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;% content_for :foo do %&gt;<br />
&lt;div&gt;This is a foo content.&lt;/div&gt;<br />
&lt;% end %&gt;<br />
<br />
&lt;% has_content? :foo &nbsp;# =&gt; true %&gt;<br />
&lt;% has_content? &quot;foo&quot; # =&gt; true %&gt;</div></td></tr></tbody></table></div>
<h3>Title Helper</h3>
<p>Provides an helper for managing page title in Rails views and layouts.</p>
<div class="codecolorer-container text default brush: ruby; html-script: true" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"># Include the helper in your controller.<br />
# You might want to include it in ApplicationController to make it available<br />
# always and everywhere in your templates.<br />
class ApplicationController &lt; ActionController::Base<br />
&nbsp; helperful :title<br />
end<br />
<br />
# Now you can use set a title in your action<br />
# Example. index.html.rb<br />
&lt;h1&gt;&lt;%= title 'This is a title' %&gt;&lt;/h1&gt;<br />
<br />
# And print the title with a :site decorator in your layout.<br />
&lt;%= title :site =&gt; 'My Cool Site!' %&gt;<br />
<br />
&lt;%= yield %&gt;</div></td></tr></tbody></table></div>
<h2>Documentation and Repository</h2>
<p>Visit the <a href="http://code.simonecarletti.com/helperful">project page</a> or the <a href="http://code.simonecarletti.com/wiki/helperful">documentation</a> for further details. The repository is <a href="http://github.com/weppos/helperful">available on GitHub</a> for forking or reference. Feel free to add more helpers and send me a pull request. Please ensure new helpers come with an appropriate test suite.</p>
<p>Related posts<ol>
<li><a href='http://www.simonecarletti.com/blog/2009/03/helperful-030/' rel='bookmark' title='Helperful 0.3.0'>Helperful 0.3.0</a></li>
<li><a href='http://www.simonecarletti.com/blog/2009/08/ruby-on-rails-and-canonical-link-tag/' rel='bookmark' title='Ruby on Rails and Canonical link tag'>Ruby on Rails and Canonical link tag</a></li>
<li><a href='http://www.simonecarletti.com/blog/2009/10/tabsonrails-and-helperful-migrated-to-gemcutter/' rel='bookmark' title='TabsOnRails and Helperful migrated to Gemcutter'>TabsOnRails and Helperful migrated to Gemcutter</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.simonecarletti.com/blog/2009/02/helperful-a-large-collection-of-rails-helpers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

