Currently, the top level navigation items, that
represent "controllers" in the Rails paradigm, are hard
wired into an array in
/app/views/shared/_navigate.rhtml. These are then
referred to by name in the "actions" table in the
database. These actions represent user-accessible
controller methods in the /app/controllers/ files, and
the accessibility of the actions is controlled in the
database by the "accesses" table on a "by-group" basis,
where users are allocated to one or more groups.
We need to deal with navigation items more
programatically, so that front end designers don't have
to deal with it. We need:
To create unit and functional tests for what we want to
achieve
To create a controllers table (to contain the
navigation items - maybe we should avoid the use of the
word "controller", possible namespace clash) and
associated controller.rb to define the Controller
method. Controller will have_many actions.
To put a navigate method into
controllers/controller_controller.rb that creates a
@navigation_items array based on those controllers for
which the current user has at least one accessible action.
To change the render :partial=>"/shared/navigate" in
layouts/appication.rhtml to render :component,
:controller=>"controller", :action=>"navigate
To do a similar tidy up of actions.
_navigate.rhtml will end up just looking like
<div class="portlet">
<h4>Navigation</h4>
<ul>
<% for item in navigate %>
<li><%= link_to image_tag( item.image) + item.name,
:controller=>item.controller %></li>
<% end %>
</ul>
</div>
Logged In: YES
user_id=44915
I don't agree with methodology this. I think a better
approach would be to use a helper.
Logged In: YES
user_id=44915
I don't agree with this methodology. I think a better
approach would be to use a helper. There is no need to add
an extra table and associated controller logic when we can
get the sufficent information from other tables. Just have
the helper construct the navigation array.