Hello,
Maybe this is super-trivial…
I need to have a list of links on the left hand side of my application,
for every single page.
So, I’ve created a layout called “main” (main.rhtml) under
view/layouts, and included >layout “main”< in pretty all of my
controllers.
main.rhtml has, amongst all the other HTML stuff:
<%= render_component :controller=> ‘dli/extras’, :action=>
‘show_lookup_links’%>
This is the component to display the links:
class Dli::ExtrasController < ApplicationController
uses_component_template_root
Link=Struct.new(:name,:controller,:action)
def show_lookup_links
@links=[]
@links << Link.new(“Channels”, “/lookup/channel”, “index”)
@links << Link.new(“Password durations”,
“/lookup/password_duration”, “index”)
render :layout=>false
end
end
Now: the list of links will need to change according to the user’s
permission. So, there is quite a lot of logic involved here.
What are my options, if I don’t want to use components?
The only solution I can think of is to add a method to the general
application controller (application.rb). However, how do call such an
action from main.rhtml? It looks like I need to be able to specify
controller and action, which brings me back to components…
Can somebody please enlighten me? I feel that I am heading the wrong
way, and…
Thanks,
Merc.