Thursday 1 May 2014

How to handle routing errors and errors in general rails

http://techoctave.com/c7/posts/36-rails-3-0-rescue-from-routing-error-solution

Twitter Bootstrap modal rails delete button not working

http://stackoverflow.com/questions/12429066/twitter-bootstrap-modal-rails-delete-button-not-working?rq=1

Thursday 19 December 2013

Build a hash from an array


 We need to build a hash, and we need to build it from each element in an array.

Old way

  
def visitors_name_email
  result = {}
  visitors.each do |visitor|
    result[visitor.name] = visitor.email
  end
  result
end

New way


def visitors_name_email
  visitors.inject({}) do |result, visitor|
    result.merge(visitor.name => visitor.email)
  end
end

Monday 16 December 2013