controller - Invoking Rake::Task in rails causes "Don't know how to build task..." -
trying integrate friendly_id gem functionality on controller method.
essentially, have market object, has url created based on custom method. since it's based on custom method, friendly_id won't update url when market object gets updated. friendly_id offer redo_slugs rake task, when call within controller, tells me can't build task. running command outside works fine.
the code controller looks 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 missing something? or can not inside controller?
thank you.
calling rake task controller update model object terrible. looking @ the code rake task, can see redo_slugs
running delete_slugs
, make_slugs
tasks. there's reason not this. you'll generating slugs every market
in table, instead of 1 need.
if @ the code make_slugs can see there's no magic there. load model objects in blocks of 100 , save them.
so, first thing try. reload , save model. after that, i'd need see logs dig deeper.
Comments
Post a Comment