ruby - Loading custom classes in Rails 4 -
i'm rewriting 1 old app - rails 1.2.6 :)) - in rails 4... can imagine information overload.
it's going quite far i'm struggling 1 task should pretty obvious lacks proper documentation , there many blogs different solutions issue.
i have custom class custom text conversion functionality (using redcloth, autolinker, sanitize etc.), let's call textilize
class. it's used in models controllers guess best solution create gem it. want attack gem creation later though since it's simple one-file class.
so added textilize.rb
file /lib directory , added config.autoload_paths += %w(#{config.root}/lib)
.
it works fine , can use in app without requiring in models , controllers.
is practice in rails 4? thread-safe? if not, there way refactor without creating complete gem now?
thanks!
"is practice?" think is.
"is thread-safe?" don't know
any other way? use solution if lib crossing model , controller , simple. if rather complex, create plugin. if complex , can extended useful on other apps, create gem.
Comments
Post a Comment