1
1
101002017-03-11 14:10:51
Ruby on Rails
10100, 2017-03-11 14:10:51

How to fix a bug in the rails gem (breadcrumbs on rails)?

I do everything according to the instructions exactly like the author of the gem: https://github.com/weppos/breadcrumbs_on_rails I have already started creating a controller like his with the same name. All in all it gives me this error:

undefined method `add_breadcrumb' for MyController:Class

How to fix? ruby version: ruby ​​2.1.8p440 (2015-12-16 revision 53160) [x86_64-linux]
rail version: Rails 4.2.5.1
--------------
In general, I do the following:
in Gemfile > > open controller My write there
gem "breadcrumbs_on_rails"
bundle install
class MyController

  add_breadcrumb "home", :root_path
  add_breadcrumb "my", :my_path

  def index
     add_breadcrumb "index", index_path
  end

end

into the layouts/ application.rb view I insert into the body
<%= render_breadcrumbs :separator => ' / ' %> I
tried to insert it into show.html.erb and still gives
undefined method `add_breadcrumb' for MyController:Class

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Svirsky, 2017-03-15
@e_svirsky

The easiest way to fix a gem is to write a monkey patch for the gem method. And immediately on the github to fix it in the near future. Until then, use the monkey patch.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question