尝试访问 localhost:3000/static_pages/home 时出现以下错误:
SyntaxError in StaticPagesController#home
/Users/user/Sites/rails_projects/sample_app/app/helpers/application_helper.rb:9: syntax error, unexpected keyword_end, expecting $end
Rails.root: /Users/user/Sites/rails_projects/sample_app
Application Trace | Framework Trace | Full Trace
app/controllers/application_controller.rb:1:in `<top (required)>'
app/controllers/static_pages_controller.rb:1:in `<top (required)>'
routes.rb 内容:
SampleApp::Application.routes.draw do
get "static_pages/home"
get "static_pages/help"
get "static_pages/about"
get "static_pages/contact"
end
application_helper.rb 内容:
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
end
static_pages_controller.rb 内容:
class StaticPagesController < ApplicationController
def home
end
def help
end
def about
end
def contact
end
end