Need advice: Structure of Rails views for submenus?

前端 未结 2 604
执念已碎
执念已碎 2021-01-19 13:23

Imagine to have two RESTful controllers (UsersController, OffersController) and a PagesController (used for static content such as index, about and so on) in your applicatio

2条回答
  •  情歌与酒
    2021-01-19 14:03

    Typically, I would abstract out the menuing functionality so that I have a helper method for rendering the Admin menu. This way, it's possible to throw as much logic in the helper as you want without clouding up your view logic.

    So, your helper would look like (forgive the ruby/rails pseudo-code, it's been a month or two since I touched it):

    def render_admin_menu()
      if !current_path.contains('offer')
        render :partial => 'shared/admin_menu'
      end
    end
    

提交回复
热议问题