Skip to content

Instantly share code, notes, and snippets.

@somu45
somu45 / Interview_questions.md
Created September 9, 2017 13:57
Ruby, Rails and Sql Specific Questions

Rails

  1. Fix the following snippet. Given a collection of 1000 draft Articles, update all of them to be published

    Post.where(status: :draft).each { |p| p.update_attributes(status: :published}
    #Ans. Post.where(status: :draft).update_all(status: :published)
customer_ids = [1049730]
def process_vc(customer_ids)
expiry_time = (Time.now.utc + 23.days).end_of_day - AppConstantType::TIMEZONES["india"].hours
user = User.find(368)
amount = 250
reason = "Campaign Bonus"
done_arr = []
failed_arr = []
customer_ids.each{|customer_id|