Trying to integrate some friendly_id gem functionality on a controller method.
Essentially, I have a Market object, which has its URL created based on a custom method. Since it's based on a custom method, friendly_id won't update the URL when the Market object gets updated. Friendly_id does offer a redo_slugs rake task, but when I call it from within my controller, it tells me that it can't build the task. Running the command outside works just fine.
The code for my controller looks like this:
require 'rake'
require 'friendly_id'
class Admin::MarketsController < ApplicationController
def update
if @market.update_attributes(params[:market])
rake_market_slugs
end
end
protected
def rake_market_slugs
Rake::Task["friendly_id:redo_slugs MODEL=Market"].invoke
end
end
Am I missing something? Or can I just not do this inside my controller?
Thank you.