Skip to content

Instantly share code, notes, and snippets.

View aldesantis's full-sized avatar

Alessandro Desantis aldesantis

View GitHub Profile
module Crowdster
module Models
module Campaigner
def included(klass)
klass.class_eval do
has_many :campaigns, class_name: 'Crowdster::Campaign'
end
end
end
end
module Crowdster
module ActsAsCampaigner
def included(klass)
klass.extend ClassMethods
end
module ClassMethods
def acts_as_campaigner
has_many :campaigns, class_name: 'Crowdster::Campaign'
module Crowdster
class Engine < ::Rails::Engine
isolate_namespace Crowdster
config.to_prepare do
if Crowdster.config
Crowdster.config.user_class.constantize.class_eval do
has_many :campaigns, class_name: 'Crowdster::Campaign'
end
end
module Crowdster
module Api
class ApplicationController < Crowdster.config.base_controller.constantize
end
end
end
module Crowdster
class << self
attr_reader :config
def configure
@config = Configuration.new
yield config
end
end
end
module Crowdster
class Configuration
attr_accessor :setting1, :setting2
end
end
MyEngine.configure do |config|
# Description of the setting here...
config.setting1 = :value
end
@aldesantis
aldesantis / images.html
Created November 3, 2015 12:06
Responsive images
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="utf-8">
<title>Immagini</title>
<style>
.container {
max-width: 500px;
var myApp = angular.module('myApp');
myApp.directive('selectPicker', function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
$(element).selectpicker();
$(element).change(function() {
require 'rails_helper'
RSpec.feature 'The home page' do
scenario 'Visiting the home' do
visit '/'
expect(page).to have_content I18n.t('pages.home.heading')
end
end