app/controllers/cms/viewables_controller.rb
def create
      current_count = UniqueKey.where(list_key_params).count

      if params[:max] == 'Infinity' || current_count < params[:max].to_i
        unique_key = list_key_params.merge(position: current_count + 1)

        viewable = UniqueKey.create_localized_viewable!(unique_key)

        if unique_key[:viewable_type] != 'Viewable::Block'
          path = rails_admin.edit_path(model_name: unique_key[:viewable_type].to_s.underscore.gsub('/', '~'), id: viewable.id)

          redirect_to path
        else
          redirect_to :back
        end
      else
        redirect_to :back
      end
    end
def create
      current_count = UniqueKey.where(list_key_params).count

      if params[:max] == 'Infinity' || current_count < params[:max].to_i
        unique_key = list_key_params.merge(position: current_count + 1)

        viewable = UniqueKey.create_localized_viewable!(unique_key)

        if unique_key[:viewable_type] != 'Viewable::Block'
          path = rails_admin.edit_path(model_name: unique_key[:viewable_type].to_s.underscore.gsub('/', '~'), id: viewable.id)

          redirect_to path
        else
          redirect_to :back
        end
      else
        redirect_to :back
      end
    end
def create current_count = UniqueKey . where ( list_key_params ) . count if params [ :max ] == 'Infinity' || current_count < params [ :max ] . to_i unique_key = list_key_params . merge ( position : current_count + 1 ) viewable = UniqueKey . create_localized_viewable! ( unique_key ) if unique_key [ :viewable_type ] != 'Viewable::Block' path = rails_admin . edit_path ( model_name : unique_key [ :viewable_type ] . to_s . underscore . gsub ( '/' , '~' ) , id : viewable . id ) redirect_to path else redirect_to :back end else redirect_to :back end end
used by the add viewable link
used by the add viewable link