Last Updated: February 25, 2016
·
299
· sadfuzzy

Typus gem admin controller customization

https://github.com/typus/typus/blob/29665b42e2709a82921177aea0773f640f4c0831/app/controllers/admin/resources_controller.rb

If you want to change some object attributes on update in a typus controller, you have two methods to do this:

def set_attributes_on_create
end

def set_attributes_on_update
end

the object is available as @object_name, and request params: params[@object_name], so you can use it like:

class Admin::MyController < Admin::ResourcesController

  private

  def item_params_for_update
    params[@object_name]['attribute'] = ''

    super
  end
end