Rails 3: How to Override a Method in Stone

I want to add some code to one of the methods in the gem. In Rails 2.3.8, I added the .rb file to the config / initializers directory and everything worked fine.

Since he switched to Rail3, work on it no longer works. I tried adding mongoid_slug.rb to config / initializers and to / lib and auto_load path / lib in application.rb. Both did not work.

Inside mongoid_slug.rb I tried:

module Mongoid module Slug module ClassMethods def find_unique_slug #mycode end end end end 

and

 Mongoid::Slug::ClassMethods.module_eval do def find_unique_slug #mycode end end 

And yet both failed. Can anyone offer some tips on how a monkey to pay a stone in Rails3? Thanks!

+4
source share
1 answer

it works for me

 module Mongoid module Slug module ClassMethods def find_unique_slug #mycode end end end end 

the problem is different, I think that including this file or calling this method should include: include Abt :: I18n in ApplicationHelper or somewhere else

0
source

Source: https://habr.com/ru/post/1347213/


All Articles