weppos / breadcrumbs_on_rails

A simple Ruby on Rails plugin for creating and managing a breadcrumb navigation.
https://simonecarletti.com/code/breadcrumbs-on-rails
MIT License
944 stars 188 forks source link

undefined method `add_breadcrumb' for ApplicationController:Class #3

Closed Stillgar71 closed 13 years ago

Stillgar71 commented 13 years ago

Hi any help would be great...

I am a Rails 3 on windows devkit installed Pik to 192. Ran the gem install view below: * LOCAL GEMS *

abstract (1.0.0) actionmailer (3.0.1) actionpack (3.0.1) activemodel (3.0.1) activerecord (3.0.1) activeresource (3.0.1) activesupport (3.0.1) arel (1.0.1) babosa (0.2.0) bcrypt-ruby (2.1.2) breadcrumbs_on_rails (1.0.1) builder (2.1.2) bundler (1.0.3) cancan (1.4.1, 1.4.0) crummy (1.0.0) devise (1.1.3) erubis (2.6.6) friendly_id (3.1.7) haml (3.0.23) hpricot (0.8.3, 0.8.2) i18n (0.4.2) mail (2.2.9.1, 2.2.9) mime-types (1.16) minitest (1.6.0) mysql2 (0.2.6 x86-mingw32) nifty-generators (0.4.2) orm_adapter (0.0.3) polyglot (0.3.1) rack (1.2.1) rack-mount (0.6.13) rack-test (0.5.6) rails (3.0.1) railties (3.0.1) rake (0.8.7) rdoc (2.5.8) ruby_parser (2.0.5) sexp_processor (3.0.5) sqlite3-ruby (1.3.2 x86-mingw32) thor (0.14.4, 0.14.3) treetop (1.4.8) tzinfo (0.3.23) warden (1.0.2, 0.10.7)

What am I missing why is the helper undefined?

controller: class ApplicationController < ActionController::Base protect_from_forgery add_breadcrumb "home", :root_path end

error message undefined method `add_breadcrumb' for ApplicationController:Class

Stillgar71 commented 13 years ago

Actual controller code: sorry about the above.. class ApplicationController < ActionController::Base protect_from_forgery add_breadcrumb "home", :root_path

end

weppos commented 13 years ago

This plugin is not totally compatible with Rails 3 at the moment. Please follow the instructions in the Rails 3 section at the bottom of the Readme to make it working with Rails 3.

Stillgar71 commented 13 years ago

That worked great one additional question if you would indulge me? I am using haml instead of ERB.. Anyway you could help again much appreciated. Again thank you..

My haml first try:

navbar.span-22.last

      = render_breadcrumbs

page source

My haml second try:

navbar.span-22.last

      %a
        = render_breadcrumbs

Page source

Stillgar71 commented 13 years ago

Sorry found out this was a haml issue with translation. The fix was to " != render_breadcrumbs." Used the Unescaping HTML: "! =" . It worked great, sorry for the non breadrumb question..

avitus commented 13 years ago

I am still getting the "undefined method 'add_breadcrumb'. I'm using Rails 3.0.4 and Ruby 1.9.2. Is there anything one needs to do beyond adding to the Gemfile?

alexcwatt commented 13 years ago

Just found this link: http://www.simonecarletti.com/code/breadcrumbs_on_rails/.

I also had to use "render_breadcrumbs.html_safe".

ghost commented 13 years ago

I am still getting the "undefined method 'add_breadcrumb'. I'm using Rails 3.0.9 and Ruby 1.8.7. I also added the gem into the Gemfile, but i'm not sure where to get the "render_breadcrumbs.html_safe", is there any way to fix this?

Thanks in advance!

alexcwatt commented 13 years ago

saltanat - did you add:

include BreadcrumbsOnRails::ControllerMixin

to your application controller per the article referenced at simonecarletti.com? I had to do that... Hope you get your issue resolved.

ghost commented 13 years ago

yep, but i'm now getting this:

uninitialized constant ApplicationController::BreadcrumbsOnRails

any ideas?

thanks in advance!

alexcwatt commented 13 years ago

Sorry, no other ideas... I'm no rails expert... You can always post a question to stackoverflow if you're not able to figure it out.

Tinky commented 13 years ago

For Rails 3, restart the server or webserver if you get this :P

lorenzopagano commented 12 years ago

I still forked the gem adding the following line in the file railtie.rb:

ActionView::Base.send :include, BreadcrumbsOnRails::ActionController::HelperMethods

This solution worked fine in my rails applications and solve the "undefined method render_breacrumbs" issue.