app/controllers/api/v1/user_training_stories_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:
# - 'swam_date_like': a matching (sub)string for the UserTrainingStory.swam_date
#
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.


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 .
def index
    if params[:swam_date_like]
      filter = "%#{params[:swam_date_like]}%"
      @user_training_story = UserTrainingStory
          .where( ["swam_date LIKE ?", filter] )
          .order( 'swam_date DESC', 'updated_at DESC' )
    else
      @user_training_story = UserTrainingStory.order( 'swam_date DESC', 'updated_at DESC' )
    end
    render status: 200, json: @user_training_story
  end
def index if params [ :swam_date_like ] filter = "%#{params[:swam_date_like]}%" @user_training_story = UserTrainingStory . where ( [ "swam_date LIKE ?" , filter ] ) . order ( 'swam_date DESC' , 'updated_at DESC' ) else @user_training_story = UserTrainingStory . order ( 'swam_date DESC' , 'updated_at DESC' ) end render status : 200 , json : @user_training_story 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)