<?xml version="1.0" encoding="UTF-8"?>
<codes type="array">
  <code>
    <code>module ActionView 
  module Helpers 
    class InstanceTag 
      def to_label_tag_with_i18n(text = nil, options = {}) 
        text ||= object.class.human_attribute_name(method_name) if object.class.respond_to?(:human_attribute_name) 
 
        to_label_tag_without_i18n(text, options) 
      end 
 
      alias_method_chain :to_label_tag, :i18n 
    end 
  end 
end</code>
    <created-at type="datetime">2009-11-22T19:42:31Z</created-at>
    <description>rails 2.3.4 doen't have i18n support in labels  
http://lawrencesong.net/2009/04/i18n-label-in-rails-monkey-patch/</description>
    <id type="integer">206</id>
    <language-id type="integer">39</language-id>
    <privated type="boolean">false</privated>
    <title>i18n in labels</title>
    <updated-at type="datetime">2009-11-22T19:42:31Z</updated-at>
    <user-id type="integer">7</user-id>
  </code>
  <code>
    <code># in application_helper

def snippet(text, wordcount, omission)
 text.split[0..(wordcount-1)].join(&quot; &quot;) + (text.split.size &gt; wordcount ? &quot; &quot; + omission : &quot;&quot;)
end


# example

snippet(@post.body, 50, &quot;#{link_to &quot;More...&quot;, @post}&quot;)</code>
    <created-at type="datetime">2009-04-20T00:45:09Z</created-at>
    <description></description>
    <id type="integer">168</id>
    <language-id type="integer">39</language-id>
    <privated type="boolean">false</privated>
    <title>truncate text at a word boundry</title>
    <updated-at type="datetime">2009-04-20T00:45:43Z</updated-at>
    <user-id type="integer">7</user-id>
  </code>
  <code>
    <code>def current_action?(options)
  url_string = CGI.escapeHTML(url_for(options))
  params = ActionController::Routing::Routes.recognize_path(url_string, :method =&gt; :get)
  params[:controller] == @controller.controller_name &amp;&amp; params[:action] == @controller.action_name
end

def current_controller?(options)
  url_string = CGI.escapeHTML(url_for(options))
  params = ActionController::Routing::Routes.recognize_path(url_string, :method =&gt; :get)
  params[:controller] == @controller.controller_name
end</code>
    <created-at type="datetime">2009-01-07T01:45:56Z</created-at>
    <description>create this helper and uses link_unless_current_controller</description>
    <id type="integer">147</id>
    <language-id type="integer">39</language-id>
    <privated type="boolean">false</privated>
    <title>current_action and current_controller helpers</title>
    <updated-at type="datetime">2009-01-07T01:45:56Z</updated-at>
    <user-id type="integer">7</user-id>
  </code>
  <code>
    <code>class TabHelper
  attr_reader :html, :tabs

  def initialize(template, states)
    @template = template
    @states = states
    @html = []
    @tabs = {}
  end

  def add(action, text)
    url = { :action =&gt; action }
    html = 
      if @template.request.path.sub(/\?.*/, '') == @template.url_for(url)
        @states[:active].call(text, url)
      else
        @states[:inactive].call(text, url)
      end
    @tabs[action] = html
    @html &lt;&lt; html
  end
  alias_method :[]=, :add
  
  def [](*args)
    @tabs.values_at(*args)
  end
end

# example

module ProductsHelper
  def subnav_links
    t = TabHelper.new(self,
      :active   =&gt; Proc.new {|text, url| %|&lt;div class=&quot;current tab&quot;&gt;#{text}&lt;/div&gt;| },
      :inactive =&gt; Proc.new {|text, url| %|&lt;div class=&quot;tab&quot;&gt;#{link_to text, url}&lt;/div&gt;| }
    )
    t[:index] = 'Manage Products'
    t[:front_page] = 'Manage Front Page'
    
    '&lt;div id=&quot;tabs&quot;&gt;' +
      '&lt;div style=&quot;float: left&quot;&gt;' +
        t[:index, :front_page].join +
      '&lt;/div&gt;' +
      '&lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;' +
    '&lt;/div&gt;'
  end
end</code>
    <created-at type="datetime">2008-12-01T01:54:38Z</created-at>
    <description></description>
    <id type="integer">125</id>
    <language-id type="integer">39</language-id>
    <privated type="boolean">false</privated>
    <title>simple tabs helper</title>
    <updated-at type="datetime">2008-12-01T01:54:38Z</updated-at>
    <user-id type="integer">7</user-id>
  </code>
  <code>
    <code>  def javascript_include_all
    includes = ''
    Dir.new(&quot;#{RAILS_ROOT}/public/javascripts&quot;).each do |js|
      next if js == &quot;.&quot; or js == '..' or !js[&quot;.js&quot;]
      includes += javascript_include_tag(js) + &quot;\n&quot;
    end
  end</code>
    <created-at type="datetime">2008-11-16T16:47:57Z</created-at>
    <description>http://blog.obiefernandez.com/content/2008/06/railsconf-2008.html</description>
    <id type="integer">102</id>
    <language-id type="integer">39</language-id>
    <privated type="boolean">false</privated>
    <title>javascript_include_all</title>
    <updated-at type="datetime">2008-11-16T16:52:08Z</updated-at>
    <user-id type="integer">7</user-id>
  </code>
  <code>
    <code>  def current_url
    url_for :only_path =&gt; false, :overwrite_params=&gt;{}  
  end</code>
    <created-at type="datetime">2008-11-15T13:13:13Z</created-at>
    <description>this helper returns a current url</description>
    <id type="integer">97</id>
    <language-id type="integer">39</language-id>
    <privated type="boolean">false</privated>
    <title>current_url</title>
    <updated-at type="datetime">2008-11-15T13:13:13Z</updated-at>
    <user-id type="integer">7</user-id>
  </code>
  <code>
    <code>  # paste application_helper.rb
  def flash_message 
    messages = &quot;&quot;
    [:notice, :info, :warning, :error].each {|type|
      if flash[type]
        messages += &quot;&lt;p class=\&quot;#{type}\&quot; id=\&quot;alert\&quot;&gt;#{flash[type]}&lt;/p&gt;&quot;
      end
    }    
    messages
  end

  ####################################

  # your layout 
  &lt;%= flash_message %&gt;
	
  &lt;% content_tag :script, :type =&gt; &quot;text/javascript&quot; do %&gt;
    $('alert').style.display = 'none';
    new Effect.Appear('alert', {duration: 3});
    setTimeout(&quot;new Effect.Fade('alert');&quot;, 10000);
  &lt;% end %&gt;</code>
    <created-at type="datetime">2008-07-05T18:41:01Z</created-at>
    <description>create an application helper to manage your rails messages
concept by nando vieira [simplesideias.com.br]</description>
    <id type="integer">21</id>
    <language-id type="integer">39</language-id>
    <privated type="boolean">false</privated>
    <title>new flash helper with prototype effects</title>
    <updated-at type="datetime">2008-07-05T18:41:44Z</updated-at>
    <user-id type="integer">7</user-id>
  </code>
</codes>
