Skip to content

Instantly share code, notes, and snippets.

View ychaker's full-sized avatar

Youssef Chaker ychaker

View GitHub Profile
@skyriverbend
skyriverbend / rails_switch_branch.py
Created November 15, 2012 05:54
Rails: Switch branches and run migrations
#!/usr/local/bin/python
"""
To use this script, you must be in the root directory of a Rails project that
is using git. You should also make sure that your directory does not contain any
uncommitted changes. Then run:
$ python rails_switch_branch.py name_of_another_branch
Running the above will do the following:
@bokmann
bokmann / gist:1915372
Created February 26, 2012 08:48
Mel's solution
# Mel,
#
# Sorry, I read too much of a previous problem I had into your question and
# probably spun you off in the wrong direction. Jim's comment points you in
# the right direction, but its only going to get you so far because of a
# limitation in combining polymorphism and HasManyThrough. You will run into
# this error trying to do what you want to do:
#
# http://rubydoc.info/github/rails/rails/master/ActiveRecord/HasManyThroughAssociationPolymorphicSourceError
#
@jcasimir
jcasimir / sessions_and_conversations.markdown
Created September 11, 2011 23:07
Sessions and Conversations in Rails 3

Sessions and Conversations

HTTP is a stateless protocol. Sessions allow us to chain multiple requests together into a conversation between client and server.

Sessions should be an option of last resort. If there's no where else that the data can possibly go to achieve the desired functionality, only then should it be stored in the session. Sessions can be vulnerable to security threats from third parties, malicious users, and can cause scaling problems.

That doesn't mean we can't use sessions, but we should only use them where necessary.

Adding, Accessing, and Removing Data