Skip to content

Instantly share code, notes, and snippets.

View NaN1488's full-sized avatar

Nahuel Sciaratta NaN1488

View GitHub Profile
@NaN1488
NaN1488 / gist:7454292
Last active December 28, 2015 05:59 — forked from Alpa84/gist:7454193
class ApplicationController < ActionController::API
def status
begin
DatabaseHelper::Mysql.smrt.exec_query('SELECT id FROM customers LIMIT 1')
DatabaseHelper::Mysql.scr.exec_query('SELECT id FROM filter_prefixes LIMIT 1')
DatabaseHelper::Mysql.backend.exec_query('SELECT id FROM accounts LIMIT 1')
DatabaseHelper::Mysql.delayed_job.exec_query('SELECT id FROM delayed_jobs LIMIT 1')
status = Class.new.extend DatabaseHelper
@NaN1488
NaN1488 / application_controller.rb
Created June 14, 2013 12:43 — forked from sergio-fry/application_controller.rb
authorized_inherited_resources with cancan
class ApplicationController < ActionController::Base
# Add this to your application_controller
def self.authorized_inherited_resources
inherit_resources
before_filter :authorize_resource_with_cancan
define_method(:authorize_resource_with_cancan) do
case action_name.to_sym
when :new, :create
@NaN1488
NaN1488 / jquery_chosen_helper.rb
Last active December 15, 2015 09:39 — forked from erkattak/jquery_chosen_helper.rb
Update to work with chosen jquery plugin. If don't know the id of the select and find option by text rather than id. Whitout using execute_script
# Example:
# chosen_select 'select[name="projects"]', "ProjectA"
#
def chosen_select (css_select, option_text)
element_id = page.find(css_select)['id']
page.driver.browser.mouse.down find("##{element_id}_chzn").native
within("##{element_id}_chzn") do
find(:xpath,"//li[text()=\"#{option_text}\"]").click
end