code
stringlengths
1
1.73M
language
stringclasses
1 value
module DocumentsHelper def has_invisibles?(documents) documents.inject(false){|has, document| has = true unless visible?(document); has} end def visible?(document) document.public || user?; end end
Ruby
module ImagesHelper end
Ruby
module CustomHelpers def inside_layout(layout, &block) @template.instance_variable_set("@content_for_layout", capture(&block)); layout = layout.include?("/") ? layout : "layouts/#{layout}"; buffer = eval("_erbout", block.binding); buffer.concat(@template.render_file(layout, true)); end ...
Ruby
ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'test_help' class Test::Unit::TestCase # Transactional fixtures accelerate your tests by wrapping each test method # in a transaction that's rolled back on completion. This ensures that the # test datab...
Ruby
# Settings specified here will take precedence over those in config/environment.rb # The production environment is meant for finished, "live" apps. # Code is not reloaded between requests config.cache_classes = true # Use a different logger for distributed setups # config.logger = SyslogLogger.new # Full error repor...
Ruby
# Settings specified here will take precedence over those in config/environment.rb # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the webserver when you make code changes. config.ca...
Ruby
# Settings specified here will take precedence over those in config/environment.rb # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped # and recreated between...
Ruby
ActionController::Routing::Routes.draw do |map| # The priority is based upon order of creation: first created -> highest priority. # Sample of regular route: # map.connect 'products/:id', :controller => 'catalog', :action => 'view' # Keep in mind you can assign values other than :controller and :action # ...
Ruby
# Don't change this file. Configuration is done in config/environment.rb and config/environments/*.rb unless defined?(RAILS_ROOT) root_path = File.join(File.dirname(__FILE__), '..') unless RUBY_PLATFORM =~ /(:?mswin|mingw)/ require 'pathname' root_path = Pathname.new(root_path).cleanpath(true).to_s end ...
Ruby
#!c:/ruby/bin/ruby # # You may specify the path to the FastCGI crash log (a log of unhandled # exceptions which forced the FastCGI instance to exit, great for debugging) # and the number of requests to process before running garbage collection. # # By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log #...
Ruby
#!c:/ruby/bin/ruby require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired...
Ruby
#!c:/ruby/bin/ruby # # You may specify the path to the FastCGI crash log (a log of unhandled # exceptions which forced the FastCGI instance to exit, great for debugging) # and the number of requests to process before running garbage collection. # # By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log #...
Ruby
#!c:/ruby/bin/ruby require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired...
Ruby
#!c:/ruby/bin/ruby require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired...
Ruby
#!c:/ruby/bin/ruby require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired...
Ruby
# This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). # # Examples: # # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) # Major.create(:name...
Ruby
class CreateAllForeignKeys < ActiveRecord::Migration def self.up #add a foreign key execute <<-SQL ALTER TABLE empleados_locales ADD CONSTRAINT fk_empleados FOREIGN KEY (empleado_id) REFERENCES empleados(id) SQL execute <<-SQL ALTER TABLE empleados_locales ...
Ruby
# To change this template, choose Tools | Templates # and open the template in the editor. require 'rubygems' require 'dbf' require 'persona' require 'garantia' require 'empleado' require 'local' require 'credito' require 'cuota' require 'time' ActiveRecord::Base.establish_connection( :adapter => "postgresql", :d...
Ruby
# To change this template, choose Tools | Templates # and open the template in the editor. require 'rubygems' require 'dbf' require 'persona' require 'garantia' require 'empleado' require 'local' require 'credito' require 'cuota' require 'time' ActiveRecord::Base.establish_connection( :adapter => "postgresql", :d...
Ruby
# To change this template, choose Tools | Templates # and open the template in the editor. require 'rubygems' require 'dbf' require 'persona' require 'sexo' require 'estado_civil' require 'garantia' require 'local' require 'cuota' require 'credito' require 'empleado' ActiveRecord::Base.establish_connection( :adapte...
Ruby
class CargarDatosTiposPromociones < ActiveRecord::Migration def self.up TipoPromocion.delete_all tipo_promocion = TipoPromocion.create(:descripcion => "Promocion prueba 1") tipo_promocion.save tipo_promocion = TipoPromocion.create(:descripcion => "Promocion prueba 2") tipo_promocion.save tipo_...
Ruby
class CargarDatosSexos < ActiveRecord::Migration def self.up Sexo.delete_all sexo = Sexo.create(:descripcion => "Masculino") sexo.save sexo = Sexo.create(:descripcion => "Femenino") sexo.save sexo = Sexo.create(:descripcion => "Indefinido") sexo.save end def self.down Sexo.delete_...
Ruby
class CargarDatosEstadosCiviles < ActiveRecord::Migration def self.up EstadoCivil.delete_all estado = EstadoCivil.create(:descripcion => "Casado/a") estado.save estado = EstadoCivil.create(:descripcion => "Soltero/a") estado.save estado = EstadoCivil.create(:descripcion => "Divorciado/a") ...
Ruby
class CreateRoles < ActiveRecord::Migration def self.up create_table :roles do |t| t.string :descripcion t.timestamps end end def self.down drop_table :roles end end
Ruby
class CreateSexos < ActiveRecord::Migration def self.up create_table :sexos do |t| t.string :descripcion t.timestamps end end def self.down drop_table :sexos end end
Ruby
class CreateUsers < ActiveRecord::Migration def self.up create_table "users", :force => true do |t| t.column :login, :string t.column :email, :string t.column :first_name, :string, :limit => 80 t.column :last_name, :string, ...
Ruby
class CreateEstadoCiviles < ActiveRecord::Migration def self.up create_table :estado_civiles do |t| t.string :descripcion t.timestamps end end def self.down drop_table :estado_civiles end end
Ruby
class CreatePersonas < ActiveRecord::Migration def self.up create_table :personas do |t| t.string :cedula t.string :nombres t.string :apellidos t.date :fecha_nacimiento t.string :telefono t.string :celular t.boolean :propietario t.float :alquiler t.integer :ca...
Ruby
class CreateTipoPromociones < ActiveRecord::Migration def self.up create_table :tipo_promociones do |t| t.string :descripcion t.timestamps end end def self.down drop_table :tipo_promociones end end
Ruby
class CreateCuotas < ActiveRecord::Migration def self.up create_table :cuotas do |t| t.references :credito t.integer :numero_cuota t.date :fecha_vencimiento t.date :fecha_pago t.timestamps end end def self.down drop_table :cuotas end end
Ruby
class CreateEmpresasPersonas < ActiveRecord::Migration def self.up create_table :empresas_personas, :id => false do |t| t.integer :empresa_id, :null => false t.integer :persona_id, :null => false t.date :fecha_desde t.date :fecha_hasta t.string :cargo t.string :telefono t...
Ruby
class CreateGarantias < ActiveRecord::Migration def self.up create_table :garantias do |t| t.integer :garante_id t.integer :beneficiario_id t.date :fecha_alta t.date :fecha_tope t.float :monto_tope t.timestamps end end def self.down drop_table :garantias e...
Ruby
class CreateDirecciones < ActiveRecord::Migration def self.up create_table :direcciones do |t| t.string :puerta t.timestamps end end def self.down drop_table :direcciones end end
Ruby
class CreateEmpleadoLocales < ActiveRecord::Migration def self.up create_table :empleado_locales do |t| t.references :empleado t.references :local t.date :fecha_desde t.date :fecha_hasta t.timestamps end end def self.down drop_table :empleado_locales end end
Ruby
class CreateEmpresas < ActiveRecord::Migration def self.up create_table :empresas do |t| t.string :nombre t.string :telefono t.references :direccion t.timestamps end end def self.down drop_table :empresas end end
Ruby
class CreateEmpleadosLocales < ActiveRecord::Migration def self.up create_table :empleados_locales, :id => false do |t| t.integer :empleado_id, :null => false t.integer :local_id, :null => false t.date :fecha_desde t.date :fecha_hasta t.timestamps end end def self.down ...
Ruby
class CreateCreditos < ActiveRecord::Migration def self.up create_table :creditos do |t| t.references :persona t.references :local t.integer :empleado_otorgador_id t.integer :empleado_vendedor_id t.integer :cantidad_cuotas t.date :fecha_credito t.boolean :diferido t...
Ruby
class CreateLocales < ActiveRecord::Migration def self.up create_table :locales do |t| t.string :nombre t.timestamps end end def self.down drop_table :locales end end
Ruby
class CargarDatosRoles < ActiveRecord::Migration def self.up Rol.delete_all Rol.create(:descripcion => "Hijo/a") Rol.create(:descripcion => "Conyugue") end def self.down Rol.delete_all end end
Ruby
class CreateNucleoFamiliares < ActiveRecord::Migration def self.up create_table :nucleo_familiares do |t| t.integer :persona_responsable_id t.integer :persona_integrante_id t.references :rol t.timestamps end end def self.down drop_table :nucleo_familiares end end
Ruby
class CreateEmpleados < ActiveRecord::Migration def self.up create_table :empleados do |t| t.string :nombre t.timestamps end end def self.down drop_table :empleados end end
Ruby
class CreatePersonasTipoPromociones < ActiveRecord::Migration def self.up create_table :personas_tipo_promociones, :id => false do |t| t.integer :tipo_promocion_id, :null => false t.integer :persona_id, :null => false t.date :fecha t.timestamps end end def self.down drop_tabl...
Ruby
class CreateAllIndexes < ActiveRecord::Migration def self.up add_index :empleados_locales, [:empleado_id, :local_id] add_index :empleados_locales, [:local_id, :empleado_id] end def self.down drop_index :empleados_locales, [:empleado_id, :local_id] drop_index :empleados_locales, [:local_id, :emple...
Ruby
class CreateEmpleadosLocales < ActiveRecord::Migration def self.up create_table :empleados_locales, :id => false do |t| t.integer :empleado_id, :null => false t.integer :local_id, :null => false t.date :fecha_desde t.date :fecha_hasta t.timestamps end end def self.down ...
Ruby
ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'test_help' class ActiveSupport::TestCase # Be sure to include AuthenticationSystem in Application Controller instead include AuthenticatedSystem # Transactional fixtures accelerate your tests by wrappi...
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/destroy'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info" require 'commands/about'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/runner'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/runner'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/server'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/generate'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/destroy'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/plugin'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/console'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/dbconsole'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info" require 'commands/about'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/server'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/dbconsole'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/console'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/plugin'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../../config/boot', __FILE__) require 'commands/performance/benchmarker'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../../config/boot', __FILE__) require 'commands/performance/profiler'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../../config/boot', __FILE__) require 'commands/performance/benchmarker'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../../config/boot', __FILE__) require 'commands/performance/profiler'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/generate'
Ruby
module EmpleadoLocalesHelper end
Ruby
module NucleoFamiliaresHelper end
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper end
Ruby
module EstadoCivilesHelper end
Ruby
module EmpresasHelper end
Ruby
module SexosHelper end
Ruby
module CreditosHelper end
Ruby
module PersonasHelper end
Ruby
module SessionsHelper end
Ruby
module TipoPromocionesHelper end
Ruby
module RolesHelper end
Ruby
module UsersHelper end
Ruby
module GarantiasHelper end
Ruby
module EmpleadosHelper end
Ruby
module LocalesHelper end
Ruby
module CuotasHelper end
Ruby
module DireccionesHelper end
Ruby
require 'active_record' class Persona < ActiveRecord::Base #Asociaciones belongs_to :direccion belongs_to :sexo belongs_to :estado_civil has_and_belongs_to_many :empresas has_and_belongs_to_many :tipo_promociones has_many :garantia_garantes, :class_name => "Garantia", :foreign_key => "beneficiario_id" ...
Ruby
class Rol < ActiveRecord::Base #Validaciones validates_presence_of :descripcion validates_uniqueness_of :descripcion end
Ruby
require 'active_record' class Empleado < ActiveRecord::Base #Asociaciones has_many :locales , :through => :empleado_locales has_many :creditos_otorgados, :class_name => "Credito", :foreign_key => ":empleado_otorgador_id" has_many :creditos_vendidos, :class_name => "Credito", :foreign_key => ":empleado_vendedo...
Ruby
require 'active_record' class Garantia < ActiveRecord::Base #Asociaciones belongs_to :garante, :class_name => "Persona", :foreign_key => "garante_id" belongs_to :beneficiario, :class_name => "Persona", :foreign_key => "beneficiario_id" #Validaciones validates_presence_of :garante_id, :beneficiario_id, :fech...
Ruby
class NucleoFamiliar < ActiveRecord::Base #Asociaciones belongs_to :rol belongs_to :persona_responsable,:class_name => "Persona", :foreign_key => "persona_responsable_id" belongs_to :persona_integrante,:class_name => "Persona", :foreign_key => "persona_integrante_id" #Validaciones validates_presence_of :pe...
Ruby
require 'active_record' class Empresa < ActiveRecord::Base #Asociaciones belongs_to :direccion has_and_belongs_to_many :personas #Validaciones validates_presence_of :nombre, :telefono validates_uniqueness_of :nombre end
Ruby
require 'active_record' class Sexo < ActiveRecord::Base #Asociaciones has_many :personas #Validaciones validates_presence_of :descripcion validates_uniqueness_of :descripcion end
Ruby
require 'active_record' class Credito < ActiveRecord::Base #Asociaciones belongs_to :persona belongs_to :local belongs_to :empleado_otorgador,:class_name => "Empleado", :foreign_key => "empleado_otorgador_id" belongs_to :empleado_vendedor,:class_name => "Empleado", :foreign_key => "empleado_vendedor_id" ha...
Ruby
require 'active_record' class TipoPromocion < ActiveRecord::Base #Asociaciones has_and_belongs_to_many :personas #Validaciones validates_presence_of :descripcion validates_uniqueness_of :descripcion end
Ruby
require 'active_record' class EstadoCivil < ActiveRecord::Base #Asociaciones has_many :personas #Validaciones validates_presence_of :descripcion validates_uniqueness_of :descripcion end
Ruby
require 'digest/sha1' class User < ActiveRecord::Base # Virtual attribute for the unencrypted password attr_accessor :password validates_presence_of :login, :email validates_presence_of :password, :if => :password_required? validates_presence_of :password_confirmation, :if ...
Ruby
class Cuota < ActiveRecord::Base belongs_to :credito end
Ruby
require 'active_record' class Direccion < ActiveRecord::Base has_many :empresas has_many :personas end
Ruby
class EmpleadoLocal < ActiveRecord::Base belongs_to :empleado belongs_to :local end
Ruby
require 'active_record' class Local < ActiveRecord::Base #Asociaciones has_many :empleados, :through => :empleado_locales #Validaciones validates_presence_of :nombre validates_uniqueness_of :nombre #, :message => 'hola' end
Ruby
class CuotasController < ApplicationController # GET /cuotas # GET /cuotas.xml def index @cuotas = Cuota.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @cuotas } end end # GET /cuotas/1 # GET /cuotas/1.xml def show @cuota = Cuota.find(par...
Ruby
class SexosController < ApplicationController # GET /sexos # GET /sexos.xml def index @sexos = Sexo.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @sexos } end end # GET /sexos/1 # GET /sexos/1.xml def show @sexo = Sexo.find(params[:id]) ...
Ruby
class EmpresasController < ApplicationController # GET /empresas # GET /empresas.xml def index @empresas = Empresa.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @empresas } end end # GET /empresas/1 # GET /empresas/1.xml def show @empres...
Ruby