Chapter 5 of Michael Hartl’s guide

I’m working on Chapter 5 of the Michael Hartl guide Ruby on Rails Tutorial and I have this error when running the rails server:

undefined method `full_title'

On this line of code in the application.html.erb page:

 <title><%= full_title(yield(:title)) %></title>

Found a solution on StackOverflow that solved the error:

def full_title(page_title)
  base_title = "Ruby on Rails Tutorial Sample App"
  if page_title.empty?
    base_title
  else
    "#{base_title} | #{page_title}"
  end
 end

I had to define the full_title method in the application_helper.rb page. (Why the helper page?) And then add this to the application_controller.rb page:

include ApplicationHelper

Source: http://stackoverflow.com/questions/23630949/undefined-method-full-title

Advertisements