Skip to content

Instantly share code, notes, and snippets.

View blahutka's full-sized avatar

blahutka blahutka

View GitHub Profile
@blahutka
blahutka / validations_for.rb
Created September 24, 2024 08:11 — forked from ismasan/validations_for.rb
Declarative AM validations depending on arbitrary attributes
# class Page
# include ValidationsFor
#
# validations_for page_type: 'offer' do
# validates :amount, presence: true
# end
#
# validations_for page_type: 'page' do
# validates :title, presence: true
# end
@dhh
dhh / Gemfile
Created June 24, 2020 22:23
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
@pioz
pioz / engines.md
Created August 29, 2019 14:48
Using webpacker inside a Rails engine

Using in Rails engines

If the application UI consists of multiple frontend application, you'd probably like to isolate their building too (e.g. if you use different frameworks/versions). Hence we needed our webpack(-er) to be isolated too: separate package.json, dev server, compilation process.

You can do this by adding another Webpacker instance to your application.

This guide describes how to do that using Rails engines.

Step 1: create Rails engine.

@ondrejbartas
ondrejbartas / how_to_setup_cypress_with_rails_app.md
Last active April 2, 2021 01:15
How to setup Cypress on Rails apps

How to setup Cypress on Rails apps

You need to update circle.yml:

machine:
  node: # add node dependency
    version:
      7.4

environment:
@dux
dux / decorator_clone.rb
Last active October 20, 2023 13:51
Simple ruby decorators with example
class DecoratorClone
def initialize(model)
@model = model
end
def method_missing(m, *args)
raise NameError, "Decorator method '#{m}' not found" unless @model.respond_to?(m)
@model.send(m, *args)
end
end
@pablobm
pablobm / README.md
Last active June 3, 2022 10:07
A clear convention for a CRUD with standard Ember + Ember Data

CRUD with Ember (+ Data)

Compatible with Ember 1.13.0+ Compatible with Ember Data 1.13.0+

Ember's official documentation describes a number of low-level APIs, but doesn't talk much about how to put them together. As a result, a simple task such as creating a simple CRUD application is not obvious to a newcomer.

@juriansluiman
juriansluiman / comments.tag
Created January 28, 2015 10:49
The react tutorial for riot
<comment-box>
<h1>{ opts.title }</h1>
<comment-list url={ opts.url } comments={ comments } />
<comment-form url={ opts.url } />
this.comments = []
add(comment) {
this.comments.push(comment)
@jules2689
jules2689 / README.md
Last active January 31, 2019 10:17
Tracking users' actions throughout an application in an "activity feed"

What this does

This is the initial code. Improvements are likely to be had.

  • This creates an activity feed that can track updates, destroys, creates in a MySQL database.
  • This is inspired by part of the "public_activity" gem.
  • For Updates, what changed will be automatically stored as a hash.
  • Bootstrap's usage is assumed, as is Devise's "current_user". ActiveRecord must be used as well. These can easily be changed however.

How to use it

module CapybaraWithPhantomJs
include Capybara
# Create a new PhantomJS session in Capybara
def new_session
# Register PhantomJS (aka poltergeist) as the driver to use
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app)
end
@tonycoco
tonycoco / controller_spec.rb
Last active May 25, 2023 06:04
The Greatest Hits of Rspec Testing: Volume 1
require "spec_helper"
describe ExampleController do
context "GET #index" do
let(:resources) { FactoryGirl.create_list(:resource) }
before do
get :index
end