Topic: Navigation development...

Hello all,

I'm fairly new to rails, but have been progressing through some tutorials and feel I can understand most code (if I stare at it long enough) and now I've gotten to the point where I would like to create my own app. It's a simple, personal site, with a blog, portfolio section, contact, about.

But, I was wondering about how to go about setting up a navigation system. I've done alot of searches and haven't found anything. There are some but they require a plugin of sorts. I was looking for one that doesn't require plugins so I can actually understand what goes on in the code.

I can probably hard code it, with the about, contact links pointing to static html pages, and the blog, portfolio links pointing to their respective controllers, but it would be nice to be able to generate pages (CRUD) dynamically and have their output in a menu system. Sounds like a CMS.

I would appreciate any input on this. Thank you.

Re: Navigation development...

I've been googling, yahooing nad msnliving and scimmed through every known forum about this aswell. Also I've been experimenting with the views for too long without progress.

I havn't had any luck finding anything on the topic I'm afraid.

If you've figured it out yet please share what you've learned smile

Kind regards
Aerpe

Re: Navigation development...

I don't understand exactly what you are after. Surely you just create the controllers and models and then the views have dynamic data that is pulled out of your database yes?

So you would have your CRUD functions that create your Create, Read, Update and Delete your Blog entries yes? Perhaps you would have an admin blog controller restricted by password that will allow you to make and alter your posts and a public Blog controller that allows people to access your blog to view.

I don't know if this is what you mean but you mention CRUD so I think this is the best way I can say to make this kind of site, if I am completely off the mark then I think you need to be clearer about what your requirements are ....

Re: Navigation development...

Howto go about creating the navigation for the website dynamicaly I'd say.

I.e. I have Categories, when I create a new category this should be added to the Navigation list.

layouts/application.html.erb

<div id="navigation">
<ul>
  <% for category in @categories %>
  <li><a href="<%= category_path(category) %>"><%= category.name %></a></li>
  <% end %>
</ul>
</div>


I tried this approach or something simulair when I played around last night, can't remember exactly.

application_controller.rb

before_filter :load_category_navigation

private




def load_category_navigation
if @categories.empty?
  if @category.empty?
   @cat_nav = Category.find(:all)
  else
   @cat_nav = @category
  end
else
  @cat_nav = @categories
end
end


and

layouts/application.html.erb

<div id="navigation">
<ul>
  <% for cat_nav in @cat_nav %>
  <li><a href="<%= cat_nav_path(cat_nav) -%>"><%= cat_nav.name -%></a></li>
  <% end %>
</ul>
</div>


EDIT: I'm a newbie so this might be a stupid solution.

Last edited by Aerpe (2008-04-22 10:12:11)