My question is very simple but I could not find a correct answer for it. I have a rake task which invokes a model method.
task :post do
BufferPreference.post
end
It doesn’t work and throws the error
uninitialized constant BufferPreference
I tryied adding the following require: require ‘buffer_preferences’ but I get the error
no such file to load — buffer_preference
My model is defined as follows:
class BufferPreference < ActiveRecord::Base
in the file buffer_preference.rb
If you want to run controller action as a method from the controller, it is not good practice. Try to move your code, into a
Model.Try this:
BufferPreference.postthat means you should haveBufferPreferencemodel, with class method calledpost.