Skip to main content

Posts

Showing posts with the label breadcrumbs implementation in ror

How to implement breadcrumbs functionality in Ruby on Rails app?

Breadcrumbs are graphical control element used as navigational aid in user interfaces. Today I am going to explain how it can be implemented in Ruby on Rails in simple steps as follows: Step 1: Create a sample app using scaffold Step 2: Add"breadcrumbs_on_rails" gem to the Gemfile and install it. Step 3: Create a home.html.erb in articles for home page and route for it. --> app/views/articles/home.html.erb Welcome This is the home page of Sample Article <%= link_to "Articles", articles_path%> --> config/routes.rb root 'articles#home' Step 4: Add breadcrumb for home page. In Articles Controller create method “add_breadcrum” to set the braedcrumb for home path like this: --> app/controllers/articles_controller.rb defadd_breadcrum add_breadcrumb " Home ".html_safe end For every view page set home page as the first breadcrumb in articles controller by the default using: before_action :add_breadcrum...