
I've a problem as follows..
1] I Created a Controller called pages_controller.rb
Code:
class PagesController < ApplicationControllerdef index
primary
render('primary')
end
def primary
@pages = Page.find(:all, :conditions => ["IsParent = ? or Name = ?",true, "Home"], :order => 'id')
end
def secondary
@pages = Page.find(:all, :conditions => ['ParentID = ?', params[:id]], :order => 'id')
@parentpage=Page.find(params[:id])
if @pages.count<=0
@parentpage.IsParent=false
redirect_to(:action => 'primary')
else
@parentpage.IsParent=true
end
@parentpage.save
end
end
and in View, I'm listing all the page like this
Code:
<% pages ||= [] %><ul>
<% pages.each do |page| %>
<% if page.Name=="Home" %>
<li><%= link_to_unless_current(page.Name, :action => 'index') %></li>
<% else %>
<li><%= link_to_unless_current(page.Name, :action => 'show', :id => page.UrlWord) %></li>
<% end %>
<% end %>
</ul>
Finally, my question is how to call a Action secondary in this view?