I am using the following gem in my rails application:
http://github.com/fnando/post_commit
I am trying to learn how to send data to service providers such as Campfire on creation of a record in my application.
Using Campfire as a test I have the following in my kase.rb model:
# Campfire
post_commit :campfire do
authorize :subdomain => "XXXXXXXXXX", :token => "XXXXXXXXXXXX", :room => 'XXXXXXX'
post "New Record", :type => :text
end
the following in my kases_controller.rb:
# POST /kases
# POST /kases.xml
def create
@company = Company.find(params[:kase][:company_id])
@kase = @company.kases.create!(params[:kase])
respond_to do |format|
@kase.sendtocampfire if params[:send_to_campfire]
#flash[:notice] = 'Record was successfully created.'
flash[:notice] = fading_flash_message("Record was successfully created.", 5)
format.html { redirect_to(@kase) }
format.xml { render :xml => @kase, :status => :created, :location => @kase }
end
end
and the following in my view:
<%= check_box_tag :send_to_campfire, 1, true %> Send Case to Campfire?
When using the code above, I get an error of:
NoMethodError in KasesController#create
undefined method `post_commit' for #<Class:0x10528e3e8>
Could someone point me in the right direction, please?
Thanks,
Danny
You may need to explicitly
require
thepost_commit
before use or, better still, make sure you have the following inenvironment.rb
in yourRails::Initializer.run
block