Better way for creating menu n rails, whe can i read about this?

12 views
Skip to first unread message

Dmitrij B.

unread,
Apr 16, 2013, 9:50:52 AM4/16/13
to rubyonra...@googlegroups.com
Hey

Better way for creating menu in rails, whe can i read about this? Wich
gems better use or manually add? Maybe have topics about this, whe can i
read more?

--
Posted via http://www.ruby-forum.com/.

Robert Walker

unread,
Apr 16, 2013, 10:22:13 AM4/16/13
to rubyonra...@googlegroups.com
Dmitrij B. wrote in post #1105858:
> Hey
>
> Better way for creating menu in rails, whe can i read about this? Wich
> gems better use or manually add? Maybe have topics about this, whe can i
> read more?

You question is really to vague to answer properly. There are many
different kinds of menus and many implementations. It depends very much
on your specific needs.

A lot of the time I create my own menus manually using CSS and
JavaScript when necessary. Other times I use a pre-built implementation.

There are many, as you can see here:
https://www.ruby-toolbox.com/categories/rails_menu_builders

Or if you want a fully JavaScript implementation:
http://jqueryui.com/menu/#icons

Dmitrij B.

unread,
Apr 16, 2013, 1:30:24 PM4/16/13
to rubyonra...@googlegroups.com
I did not mean html and css. I mean rails way. Maybe have helpers for
this or use partial or better practice in rails

Robert Walker

unread,
Apr 16, 2013, 7:59:00 PM4/16/13
to rubyonra...@googlegroups.com
Dmitrij B. wrote in post #1105899:
> I did not mean html and css. I mean rails way. Maybe have helpers for
> this or use partial or better practice in rails

Which is precisely why I linked to the list on ruby-toolbox. They are
examples of menu systems designed to work with Rails. And their
respective web sites and GitHub pages should give you plenty of content
to read up on in choosing the right solution for your needs.

But, as I said choosing a solution is highly dependent on how complex
your menu needs are. Some navigation systems are really simple and can
be done entirely manually, others may benefit from one of those gems in
the list.

And yes, use of partials and helpers are beneficial, but that's
completely independent of what you are building. It makes no difference
whether it is a menu that you're sharing, or anything else generic
enough to share, that's the purpose of a partial. Helpers are generally
used to move complex logic out of the view template, their role remains
the same regardless of what you're building.

Bigos

unread,
Apr 17, 2013, 5:12:48 AM4/17/13
to rubyonra...@googlegroups.com
There is no one best way of creating menus, because people's needs vary.

One simple example of creating menu you can find here:
https://github.com/bigos/openshift-chrisbim/blob/master/app/views/layouts/application.html.haml
line 26:   = render :partial => 'layouts/navbar'

Then in partial I had following code:
https://github.com/bigos/openshift-chrisbim/blob/master/app/views/layouts/_navbar.html.haml

And this is relevant css:
https://github.com/bigos/openshift-chrisbim/blob/master/app/assets/stylesheets/style.css.scss
Please have a look at likes 57 to 72

Jacek
Reply all
Reply to author
Forward
0 new messages