app/controllers/api/v1/trainings_controller.rb
# Returns a JSON-encoded Array of all the 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:
# - 'title_like':    a matching (sub)string for the Training.title
#
Returns a JSON-encoded Array of all the 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:
'title_like':    a matching (sub)string for the Training.title
Returns a JSON - encoded Array of all the 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 : ' title_like ' : a matching ( sub ) string for the Training . title
def index
    if params[:title_like]
      filter = "%#{params[:title_like]}%"
      @trainings = Training.where( ["title LIKE ?", filter] )
          .order( 'updated_at DESC', 'title' )
    else
      @trainings = Training.order( :title ).all
    end
    render status: 200, json: @trainings
  end
def index if params [ :title_like ] filter = "%#{params[:title_like]}%" @trainings = Training . where ( [ "title LIKE ?" , filter ] ) . order ( 'updated_at DESC' , 'title' ) else @trainings = Training . order ( :title ) . all end render status : 200 , json : @trainings end
Returns a JSON-encoded Array of all the rows.
Returns a JSON - encoded Array of all the rows .
# (This uses Squeel DSL syntax for where clauses)