Using this previous question as a guide, I've attempted to create a ul
navigation header above a container that renders partials within the container when clicked. (Hopefully that makes some sense, but it may not be important.) Until 开发者_StackOverflow中文版the links for the partials are clicked, I have it rendering a partial by default.
However, when I went to click my link_to
in hopes of rendering the partial I get the following error:
uninitialized constant ProfileController
I'm using Rails 3. Here's my relevant code:
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'
Can anyone help me fix this and explain what went wrong?
Both of your routes are incorrect.
If your controller is indeed named ProfilesController
(plural) then your routes should use :controller => 'profiles'
, instead of :controller => 'profile'
.
精彩评论