lib/rails_powergrid/concern/grid_concern.rb
# UPDATE ONE OR MORE FIELD TO ONE MODEL
UPDATE ONE OR MORE FIELD TO ONE MODEL
UPDATE ONE OR MORE FIELD TO ONE MODEL
def update_field
    begin
      load_resource
      param_permits.each do |k,v|
        @grid.get_column(k).set(@resource, v)
      end
      if @resource.save
        render :json => @grid.get_hash(prepare_collection_query.where(id: @resource.id).first)
      else
        render :json => {status: "ERROR", errors: @resource.errors.messages }, status: :unprocessable_entity
      end
    rescue ActiveRecord::RecordNotSaved, ActiveRecord::RecordInvalid
      render :json => {status: "ERRORS", errors: @resource.errors.messages }, status: :unprocessable_entity
    end
  end
def update_field begin load_resource param_permits . each do | k , v | @grid . get_column ( k ) . set ( @resource , v ) end if @resource . save render :json => @grid . get_hash ( prepare_collection_query . where ( id : @resource . id ) . first ) else render :json => { status : "ERROR" , errors : @resource . errors . messages } , status : :unprocessable_entity end rescue ActiveRecord :: RecordNotSaved , ActiveRecord :: RecordInvalid render :json => { status : "ERRORS" , errors : @resource . errors . messages } , status : :unprocessable_entity end end
UPDATE ONE OR MORE FIELD TO ONE MODEL
UPDATE ONE OR MORE FIELD TO ONE MODEL
#This case can occurs when one field is a compound field and call "save!" method for example.