03
Sep
11

rails sublayout



I wanted to display a tag cloud, only for a controller named Snippets. I asked on StackOverflow first, but the question didn’t receive many views ( maybe because if I would have read the documentation better, I would have found the answer 🙂 ). Anyway, here’s how I accomplished that:

In the Snippets controller, I added:


layout "snippets"

In the application layout, I added:


<% if content_for?(:tag_cloud) %>
	<%= content_for(:tag_cloud) %>
<% end %>

I created a snippets layout, and I added this inside it:


<%= content_for(:tag_cloud) do %>
	<%= content_tag :div,:class => "span-24" do %>
		<%= render "shared/tag_cloud" %>
	<% end %>
<% end %>	
<%= render :file => "layouts/application" %>

Advertisements

0 Responses to “rails sublayout”



  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Blog Stats

  • 229,426 hits

%d bloggers like this: