Register • FAQ • Memberlist • Usergroups • Tutorials Point • Log in

| Page 1 of 1

Call Controller Actions in View
Author | Message
--- | ---
shreekumar Joined: 21 Aug 2011 Posts: 1 Location: Mysore | Call Controller Actions in View Hi guys, basically i'm .Net Developer, now learning RoR I've a problem as follows.. 1] I Created a Controller called pages_controller.rb

###### Code:

class PagesController < ApplicationController
def 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?
Sun Aug 21, 2011 3:37 pm |

Display posts from previous: |

| Page 1 of 1

You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum

Powered by phpBB © phpBB Group Design by Vjacheslav Trushkin for phpBBStyles.com