View gist:13913
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Socios < Application | |
# Definimos el tipo de información que servirá este controlador | |
provides :json | |
def lista | |
begin | |
if params[:estatus].nil? | |
# Si no hay especificado un estatus, desplegamos todos los clientes | |
@resultado[:datos] = Cliente.all |
View gist:13980
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) | |
subclass.declara_excepciones | |
end |
View gist:14409
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
# http://github.com/lobo-tuerto/dm-core/commit/c2103bc1789c05685fb111194635fa13f5707ea9 | |
class Entity | |
include DataMapper::Resource |
View gist:15548
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@operaciones = all(:servicio_id => @servicio.id, :tipo_de_operacion_id => @tipo_de_operacion_ids).serialize | |
@operaciones.map! {|i| i[:nombre] = @tipo_de_operacion.find{|to| to.id == i[:tipo_de_operacion_id]}.nombre; i} |
OlderNewer