Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1. Question.count
- 2. Lingo.find(16)
- 3. Lingo.find_by_term("Linux"), Lingo.where(term: "Linux").first, Lingo.find_by(term: "Linux"), Lingo.where("term = ?", "Linux").first
- 4. Question.where(user_id: 67), User.find(67).questions
- 5. User.first(500).pluck(:last_name)
- 6.*question_count = Question.group(:user_id).count
- question_count.values.max
- question_count.select {|k, v| v == 10}
- 7. Question.last.destroy
- 8. answers = Question.pluck(:answer_text)
- answer_length = answers.map {|x| x.length}
- Question.all.select {|q| q.answer_text.length == answer_length.max}
- Question.order("LENGTH(answer_text) DESC").limit(1) (FOR JUST ONE)
- 9. User.where(subscribed: true)
- 10. User.where(subscribed: false).order(:created_at).pluck(:email)
- 11. Lingo.where("created_at < ?", '2017-01-01')
- 12. Question.first(55), Question.limit(55)
- 13. Question.last(105), Question.order(id: :desc).limit(105) *first one preserves ascending order*
- 14. Question.find(231).expert.first_name
- 15. User.create(first_name: "Some", last_name: "Guy", email: "someguy@gmail.com", password: "password", password_confirmation: "password")
- 16. User.create(first_name: "Some", last_name: "Guy", email: "someotherguy@gmail.com", password: "password", password_confirmation: "password", expert: true, expert_type: "Data Science")
- 17. COMING SOON
- 18. arr_q = Question.where(question_text: "")
- arr_q.each {|question| question.question_text = "string"; question.save}
- 19. User.create(first_name: "Some", last_name: "Guy", email: "someotherguy2@gmail.com", password: "password", password_confirmation: "password", expert: true, expert_type: "User Experience Design")
- User.find_by_expert_type("design").update_attributes(expert_type: "graphic design")
- 20. Question.where(user_id: 546).each {|q| q.destroy}
- User.find(546).destroy
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement