什么是在rails 3中设置页面标题的正确方法.目前我正在做以下事情:
应用程序/视图/布局/ application.html:
<head>
<title><%= render_title %></title>
<%= csrf_meta_tag %>
Run Code Online (Sandbox Code Playgroud)
应用程序/佣工/ application_helper.rb:
def render_title
return @title if defined?(@title)
"Generic Page Title"
end
Run Code Online (Sandbox Code Playgroud)
应用程序/控制器/ some_controller.rb:
def show
@title = "some custom page title"
end
Run Code Online (Sandbox Code Playgroud)
有没有其他/更好的方法来做上述事情?
你知道,比如myblog.com/posts/donald-e-knuth.
我应该使用内置parameterize方法吗?
插件怎么样?我可以想象一个插件很适合处理重复的slug等.这里有一些流行的Github插件 - 有没有人对它们有任何经验?
基本上看起来slu is是一个完全解决的问题,我不会重新发明轮子.