app/controllers/api/v1/user_trainings_controller.rb
# Returns a JSON-encoded Array of all the available rows.
# Each array element is a JSON-encoded hash of a single row.
# The keys of the Hash are the attributes as string.
#
# === Additional params:
# - user_id:  the user_id owner of the UserTraining rows
#
Returns a JSON-encoded Array of all the available rows.
Each array element is a JSON-encoded hash of a single row.
The keys of the Hash are the attributes as string.

Additional params:
user_id:  the user_id owner of the UserTraining rows
Returns a JSON - encoded Array of all the available rows . Each array element is a JSON - encoded hash of a single row . The keys of the Hash are the attributes as string . Additional params : user_id : the user_id owner of the UserTraining rows
def index
    if params[:user_id]
      @user_trainings = UserTraining.where( user_id: params[:user_id] )
          .order('updated_at DESC')
    else
      @user_trainings = UserTraining.order('updated_at DESC').all
    end
    render status: 200, json: @user_trainings
  end
def index if params [ :user_id ] @user_trainings = UserTraining . where ( user_id : params [ :user_id ] ) . order ( 'updated_at DESC' ) else @user_trainings = UserTraining . order ( 'updated_at DESC' ) . all end render status : 200 , json : @user_trainings end
Returns a JSON-encoded Array of all the available rows.
Returns a JSON - encoded Array of all the available rows .
# (This uses Squeel DSL syntax for where clauses)