Skip to content

Instantly share code, notes, and snippets.


victor-adrian lobo-tuerto

View GitHub Profile
View gist:13913
class Sujeto
include DataMapper::Resource
# Configuración de las relaciones
# Puede tener un cliente asociado
has 1, :cliente, :child_key => [:sujeto_id]
has n, :direcciones, :child_key => [:sujeto_id]
# Puede tener muchos préstamos de socio
#has n, :prestamos, :child_key => [:sujeto_id]
#has n, :domicilios, :class_name => 'Address', :through => Resource, :child_key => [:subject_id]
View gist:13979
class Socios < Application
# Definimos el tipo de información que servirá este controlador
provides :json
def lista
if params[:estatus].nil?
# Si no hay especificado un estatus, desplegamos todos los clientes
@resultado[:datos] = Cliente.all
View gist:13980
# De esta clase heredan todos los controladores
# aquí es un buen lugar para definir métodos que puedan ser
# invocados desde cualquier controlador
class Application < Merb::Controller
# Cuando alguna clase herede de ésta le declaramos (agregamos) las
# excepciones definidas en self.declara_excepciones
def self.inherited(subclass)
View gist:14409
# Right now if you do this and run rake db:automigrate (I'm using postgresql)
# it will generate a table called authors_books with one column called entity_id
# instead of adding 2 columns to the table (book_id, author_id).
# I think that means it is getting and using the parent model from the STI hierarchy
# This was an attempt to patch it up, it's working but it's breaking one spec
class Entity
include DataMapper::Resource
View gist:15548
# This happens when trying to re-generate an app with merb-gen and overwrite it.
/usr/lib/ruby/1.8/fileutils.rb:814:in `read': Is a directory - /usr/lib/ruby/gems/1.8/gems/merb-gen-0.9.9/lib/generators/templates/application/merb/spec (Errno::EISDIR)
from /usr/lib/ruby/1.8/fileutils.rb:814:in `compare_stream'
from /usr/lib/ruby/1.8/fileutils.rb:796:in `identical?'
from /usr/lib/ruby/1.8/fileutils.rb:795:in `open'
from /usr/lib/ruby/1.8/fileutils.rb:795:in `identical?'
from /usr/lib/ruby/1.8/fileutils.rb:794:in `open'
from /usr/lib/ruby/1.8/fileutils.rb:794:in `identical?'
from /usr/lib/ruby/gems/1.8/gems/templater-0.3.1/lib/templater/actions/file.rb:42:in `identical?'
View gist:16740
/home/vcruz/.thor/merb.thor:8: warning: already initialized constant MERB_THOR_VERSION
/home/vcruz/.thor/merb.thor:1127: warning: already initialized constant DM_STACK
/home/vcruz/.thor/merb.thor:1141: warning: already initialized constant MERB_STACK
/home/vcruz/.thor/merb.thor:1152: warning: already initialized constant MERB_BASICS
/home/vcruz/.thor/merb.thor:1173: warning: already initialized constant MERB_MORE
/home/vcruz/.thor/merb.thor:1185: warning: already initialized constant MERB_PLUGINS
/home/vcruz/.thor/merb.thor:1215: warning: already initialized constant DM_MORE
View gist:16751
vcruz@vcruz-desktop:~/dev/sif$ merb --version
merb 0.9.9
vcruz@vcruz-desktop:~/dev/sif$ merb-gen app lolaz
Generating with app generator:
[ADDED] gems
[ADDED] Rakefile
[ADDED] .gitignore
[ADDED] public/.htaccess
[ADDED] app/models/merb/session.rb
[ADDED] app/views/exceptions/not_acceptable.html.erb
View gist:16990
Merb::Config.use do |c|
c[:framework] = { :support => Merb.root/'app'/'support'}
# Sets up a custom session id key which is used for the session persistence
# cookie name. If not specified, defaults to '_session_id'.
c[:session_id_key] = '_sif_session_id'
# The session_secret_key is only required for the cookie session store.
c[:session_secret_key] = '2af3df4fcfd64df54fd0010701fad98f97bee959'
# There are various options here, by default Merb comes with 'cookie',
View gist:24972
property :email, String, :nullable => false, :unique => true, :format => :email_address,
:messages => {
:presence => "We need your email address.",
:is_unique => "We already have that email.",
:format => "Doesn't look like an email address to me ..."
#The messages should map to the stuff we are validating, or else the user needs to LOOK for WHAT to set
#This should be better
View gist:30842
@operaciones = all(:servicio_id =>, :tipo_de_operacion_id => @tipo_de_operacion_ids).serialize! {|i| i[:nombre] = @tipo_de_operacion.find{|to| == i[:tipo_de_operacion_id]}.nombre; i}