【发布时间】:2011-08-25 20:16:38
【问题描述】:
使用此previous question 作为指导,我尝试在容器上方创建一个ul 导航标头,单击该标头会在容器内呈现部分内容。 (希望这有一定的意义,但它可能并不重要。)在单击部分链接之前,我让它默认呈现部分。
但是,当我点击我的link_to 以希望渲染部分内容时,我收到以下错误:
uninitialized constant ProfileController
我正在使用 Rails 3。这是我的相关代码:
ProfilesController:
def show_about
@is_on_show_about = true
end
def show_info
@is_on_show_info = true
end
views/profiles/show.html.erb:
<div id="info">
<div id="infoContainer">
<% if @is_on_show_about %>
<%= render :partial => 'show_about' %>
<% elsif @is_on_show_info %>
<%= render :partial => 'show_info' %>
<% end %>
<ul id="info">
<li>
<%= link_to 'About', show_about_path, :remote => true %>
</li>
</ul>
<ul id="settingsLinks">
<li><a href="#">Advice</a></li>
<li>
<%= link_to 'Info', show_info_path, :remote => true %>
</li>
</ul>
</div>
<%= render :partial => 'show_about' %>
Routes.rb:
map.show_info 'profiles/:id/info', :controller => 'profile', :action => 'show_info'
map.show_about 'profiles/:id/about', :controller => 'profile', :action => 'show_about'
谁能帮我解决这个问题并解释出了什么问题?
【问题讨论】:
-
您的配置文件控制器实际上是否称为
ProfileController,位于“app/controllers/profile_controller.rb”中? -
不,抱歉,这是一个错字。它是 ProfilesController,位于“app/controllers/profiles_controller.rb”中。我会在上面解决这个问题。
标签: ruby-on-rails-3 partial-views uninitialized-constant