I have a file in app/models/tag.rb
which adds a method to a class in a gem:
class ActsAsTaggableOn::Tag
def to_param
name
end
end
This is in my Gemfile:
gem 'acts-as-taggable-on'开发者_运维技巧
Problem is that, even in development mode, Rails only loads this file when the server starts. How can I tell Rails to load this file on every request, at least in development mode?
I apologize if this doesn't work (perhaps you've tried it already).
There's a ruby method load
. Call it every time your app runs. You can do that by adding it to your application_controller.rb file.
before_filter :reload_my_gem
def reload_my_gem
load "[path_to_file]"
end
(I don't know how your app and gem run; it may be that before_filter
does not make the call at the right time for your needs.)
精彩评论