Skip to content

Instantly share code, notes, and snippets.

View Base Rails Docker Compose File
version: '2'
volumes:
postgres-data:
driver: local
gems:
driver: local
services:
db:
@kurenn
kurenn / gist:9205589385479d60d409
Created Apr 8, 2015
A simple client for a simple API
View gist:9205589385479d60d409
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<form action="http://localhost:3000/tasks.json" method="post">
View Gemfile
source 'https://rubygems.org'
# Follows the bundler group pattern described here:
# http://iain.nl/getting-the-most-out-of-bundler-groups
# Gemfile.mine in root dir allows locally custom gems.
# NOTE: Doing this will change the Gemfile.lock - commit with care.
eval File.read(File.join(File.dirname(__FILE__), 'Gemfile.mine')) if File.exists? File.join(File.dirname(__FILE__), 'Gemfile.mine')
ruby '1.9.3'
@kurenn
kurenn / gist:4421177
Last active Mar 29, 2017
This gist shows how to make a polymorphic association for users in rails which have an specific role, such as Member, Admin...works with devise
View gist:4421177
##Userable
module Userable
def self.included(base)
base.has_one :user, :as => :userable, :dependent => :destroy, :autosave => true
base.validate :user_must_be_valid
base.alias_method_chain :user, :autobuild
base.extend ClassMethods
base.define_user_accessors
end
@kurenn
kurenn / LenguasIndigenas.json
Created Oct 20, 2012
Este es un formato preliminar de como se encuentra actualmente la estrucuta de la API (http://localhost:3000/archives/17.json)
View LenguasIndigenas.json
[
[
"ENTIDAD",
"LENGUA",
"TOTAL"
],
[
"Baja California",
"Chol",
@kurenn
kurenn / _form.html.erb
Created Mar 14, 2012
Problema con nested resources y un render parcial
View _form.html.erb
<div class="control-group">
<div class="controls">
<%= link_to_add_fields("Agregar producto", f, :requisitions) %>
<%= f.fields_for :requisitions do |builder| %>
<%= render :partial => 'requisition_fields', :locals => {:f => builder } %>
<% end %>
</div>
</div>