#------- retrieve last recorded moment from database ---------#
elsif body.start_with?("retrieve_") && body.include?("last")
moments = Moment.where( user_id: session["current_user"].id ).where("body IS NOT NULL")
if moments.count == 0
message = "I couldn't find a moment. Try adding one by typing 'record_' at the begining of your sentence."
else
item = moments.last
message = "On #{ item.created_at.strftime( "%d %B %Y" ) }: #{ item.body } "
end
#------- retrieve last recorded moment from database ---------#
#------- retrieve any recorded moment from database ---------#
elsif body.start_with?("retrieve_") && body.include?("anything") || body.include?("something") || body.include?("other")
moments = Moment.where( user_id: session["current_user"].id ).where("body IS NOT NULL")
if moments.count == 0
message = "I couldn't find a moment. Try adding one by typing 'record_' at the begining of your sentence."
else
item = moments.sample
message = "On #{ item.created_at.strftime( "%B %d %Y" ) }: #{ item.body } "
end
#------- retrieve any recorded moment from database ---------#
Click to Expand
Content Rating
Is this a good/useful/informative piece of content to include in the project? Have your say!
You must login before you can post a comment. .