Skip to content

Instantly share code, notes, and snippets.

View skorth's full-sized avatar

Sascha Korth skorth

View GitHub Profile
@kirel
kirel / build_sti_subclass.rb
Last active April 25, 2017 09:54
Build correct sti subclass
# STI subclass building backported from Rails 4 to use in Rails 3.2 - see
# https://github.com/rails/rails/commit/89b5b31cc4f8407f648a2447665ef23f9024e8a5
# Usage:
# include BuildStiSubclass # in your model and be done
module BuildStiSubclass
extend ActiveSupport::Concern
included do
attr_accessible inheritance_column
end
module ClassMethods
@MartijnR
MartijnR / jquery.getXPath.js
Created March 8, 2013 19:00
Get XPath from jQuery element
/**
* Creates an XPath from a node (currently not used inside this Class (instead FormHTML.prototype.generateName is used) but will be in future);
* @param {string=} rootNodeName if absent the root is #document
* @return {string} XPath
*/
$.fn.getXPath = function(rootNodeName){
//other nodes may have the same XPath but because this function is used to determine the corresponding input name of a data node, index is not included
var position,
$node = this.first(),
nodeName = $node.prop('nodeName'),
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')