Create Page Navigation with ComfortableMexicanSofa and Foundation

I am creating my first web application using Ruby on Rails (v4.1.5) , ComfortableMexicanSofa (v1.12.2) for the CMS and admin features, and Foundation 5 for the frontend.

To set up Foundation for Rails, I followed this tutorial , which generated the _navigation.html.erb

and _navigation_links.html.erb

in /app/views/layouts

, among other files.

The official documentation for ComfortableMexicanSofa has this quick tutorial on how to create navigation menus from CMS pages . Unfortunately, due to lack of experience, I cannot figure it out.

Relevant excerpt from the documentation:

Typically, you have something like this in your helper / partial:

- @cms_site.pages.root.children.published.each do |page|
  = link_to page.label, page.full_path

      

Then you can use this from app layout or CMS layout / page using a tag.

As I understand it, I need to create some kind of helper in /app/helpers

where I need to get the CMS pages and show them in my view, but I'm not sure how to implement this with Foundation.

Any advice and examples that could point me in the right direction is greatly appreciated.

+3


source to share


1 answer


You can put something like this in a view or partial:



  <nav class="navbar navbar-default" role="navigation">
    <ul class="nav navbar-nav">
      <li><%= link_to 'Home', '/' %></li>
      <% Comfy::Cms::Site.first.pages.root.children.published.each do |page| %>
        <li><%= link_to page.label, page.full_path %></li>
      <% end %>
    </ul>
  </nav>

      

+3


source







All Articles