Quantcast
Channel: Rails 3 - Ideal way to set title of pages - Stack Overflow
Browsing all 14 articles
Browse latest View live

Answer by Dennis Best for Rails 3 - Ideal way to set title of pages

There are already some good answers, but I'll add my simple approach. Add this to layouts/application.html- if content_for?(:title) -title = "My site | #{content_for(:title)}"-else -title = "My site |...

View Article



Answer by tomios for Rails 3 - Ideal way to set title of pages

In application layout:# app/views/layouts/application.html.erb<title><%= (yield :title) || 'General title' %></title>then in each view where you want a specific title:<%...

View Article

Answer by itsnikolay for Rails 3 - Ideal way to set title of pages

There's a simple way to manipulate layout variables (title, description, etc.):# app/views/application.html.erb<title><%= content_for :title || 'App default title' %></title>#...

View Article

Answer by Bruno Casali for Rails 3 - Ideal way to set title of pages

My answer is more simple:locales/any_archive.yml:pt-BR: delivery_contents: title: 'Conteúdos de Entregas' groups: title: 'Grupos'And inside of application.html.slim:title = "App Name:...

View Article

Answer by Mark Murphy for Rails 3 - Ideal way to set title of pages

I prefer this:module ApplicationHelper def title(*page_title) if Array(page_title).size.zero? content_for?(:title) ? content_for(:title) : t(:site_name) else content_for :title, (Array(page_title)...

View Article


Answer by Randy for Rails 3 - Ideal way to set title of pages

I thought it will be good:<title><% if @title %><%= @title %><% else %> Your title<% end %></title>And give a value to @title in your controller, or the title will...

View Article

Answer by ronan_mac for Rails 3 - Ideal way to set title of pages

I have a somewhat more complicated solution. I want to manage all of my titles in my locale files. I also want to include meaningful titles for show and edit pages such that the name of the resource is...

View Article

Answer by DaniG2k for Rails 3 - Ideal way to set title of pages

This is my preferred way of doing it:application_helper.rbmodule ApplicationHelper def title(*parts) content_for(:title) { (parts << t(:site_name)).join(' - ') } unless parts.empty?...

View Article


Answer by Dobromir Minchev for Rails 3 - Ideal way to set title of pages

You can also check this railscast. I think it will be very useful and give you basic start.NOTE: In case you want more dynamic pages with pjax

View Article


Answer by griable for Rails 3 - Ideal way to set title of pages

There's no need to create any extra function/helper. You should have a look to the documentation.In the application layout<% if content_for?(:title) %><%= content_for(:title) %><% else...

View Article

Answer by Jits for Rails 3 - Ideal way to set title of pages

I found that apeacox's solution didn't work for me (in Rails 3.0.3).Instead I did...In application_helper.rb:def title(page_title, options={}) content_for(:title, page_title.to_s) return...

View Article

Answer by johnmcaliley for Rails 3 - Ideal way to set title of pages

@akfalcon - I use a similar strategy, but without the helper.. I just set the default @title in the application controller and then use, <%=@title%> in my layout. If I want to override the title,...

View Article

Answer by Andrea Pavoni for Rails 3 - Ideal way to set title of pages

you could a simple helper:def title(page_title) content_for :title, page_title.to_senduse it in your layout:<title><%= yield(:title) %></title>then call it from your templates:<%...

View Article


Rails 3 - Ideal way to set title of pages

Whats the proper way to set the page title in rails 3. Currently I'm doing the following:app/views/layouts/application.html:<head><title><%= render_title %></title><%=...

View Article
Browsing all 14 articles
Browse latest View live




Latest Images