code
stringlengths
1
1.73M
language
stringclasses
1 value
# Load the rails application require File.expand_path('../application', __FILE__) # Initialize the rails application Cupido::Application.initialize!
Ruby
require 'rubygems' # Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
Ruby
require File.expand_path('../boot', __FILE__) require 'rails/all' if defined?(Bundler) # If you precompile assets before deploying to production, use this line Bundler.require(*Rails.groups(:assets => %w(development test))) # If you want your assets lazily compiled in production, use this line # Bundler.requi...
Ruby
Cupido::Application.routes.draw do get "general/home" get "general/empresa" get "general/fechas" get "general/faq" get "general/productos" #match "order/comprar" => 'articles#comprar', :as "comprar" devise_for :users, :path => "auth" resources :orders resources :events resources :users...
Ruby
module ArticlesHelper end
Ruby
module ApplicationHelper end
Ruby
module EventsHelper end
Ruby
module UsersHelper end
Ruby
module OrdersHelper end
Ruby
module CategoriesHelper end
Ruby
module GeneralHelper end
Ruby
module CombosHelper end
Ruby
class Category < ActiveRecord::Base attr_accessible :name has_many :articles validates :name, presence: true end
Ruby
class Event < ActiveRecord::Base attr_accessible :date, :name belongs_to :user validates :date, :name, presence: true end
Ruby
class Order < ActiveRecord::Base attr_accessible :delivery_date, :street, :street_number, :article_id belongs_to :user belongs_to :article #has_many :articles, :through => :article_orders validates :delivery_date, :street, :street_number, :article_id, presence: true end
Ruby
class ArticleOrder < ActiveRecord::Base attr_accessible :article_id, :order_id belongs_to :article belongs_to :order end
Ruby
class ArticleCombo < ActiveRecord::Base attr_accessible :article_id, :combo_id belongs_to :article belongs_to :combo end
Ruby
class Article < ActiveRecord::Base attr_accessible :name, :description, :picture, :prize, :category_id #código para editar, en style puedo configurar el tamaño según yo quiera has_attached_file :picture, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png" ...
Ruby
class User < ActiveRecord::Base # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable # Setup accessible (or protected) attributes for your...
Ruby
class ComboOrder < ActiveRecord::Base attr_accessible :combo_id, :order_id belongs_to :combo belongs_to :order end
Ruby
class Combo < ActiveRecord::Base attr_accessible :prize has_many :combo_orders has_many :article_combos validates :prize, presence: true, numericality: true end
Ruby
class ArticlesController < ApplicationController #before_filter :authenticate_user! # GET /articles # GET /articles.json def index @articles = Article.all end # GET /articles/1 # GET /articles/1.json def show @article = Article.find(params[:id]) respond_to do |format| format.html...
Ruby
class GeneralController < ApplicationController def home end def empresa end def fechas end def faq end def productos end end
Ruby
class EventsController < ApplicationController before_filter :authenticate_user! # GET /events # GET /events.json def index @events = Event.all respond_to do |format| format.html # index.html.erb format.json { render json: @events } end end # GET /events/1 # GET /events/1.json ...
Ruby
class OrdersController < ApplicationController before_filter :authenticate_user!, :only => [:index, :new] # GET /orders # GET /orders.json def index @orders = Order.all respond_to do |format| format.html # index.html.erb format.json { render json: @orders } end end # GET /orders/1...
Ruby
class CategoriesController < ApplicationController before_filter :authenticate_user!, :only => [:edit, :new, :show] # GET /categories # GET /categories.json def index @categories = Category.all respond_to do |format| format.html # index.html.erb format.json { render json: @categories } ...
Ruby
class CombosController < ApplicationController before_filter :authenticate_user! # GET /combos # GET /combos.json def index @combos = Combo.all respond_to do |format| format.html # index.html.erb format.json { render json: @combos } end end # GET /combos/1 # GET /combos/1.json ...
Ruby
class ApplicationController < ActionController::Base protect_from_forgery # validaciones de errores end
Ruby
class UsersController < ApplicationController # GET /users # GET /users.json def index @users = User.all respond_to do |format| format.html # index.html.erb format.json { render json: @users } end end # GET /users/1 # GET /users/1.json def show @user = User.find(params[:id]) ...
Ruby
#!/usr/bin/env rake # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require File.expand_path('../config/application', __FILE__) Cupido::Application.load_tasks
Ruby
#!/usr/bin/env ruby # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. APP_PATH = File.expand_path('../../config/application', __FILE__) require File.expand_path('../../config/boot', __FILE__) require 'rails/commands'
Ruby
#!/usr/bin/env ruby # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. APP_PATH = File.expand_path('../../config/application', __FILE__) require File.expand_path('../../config/boot', __FILE__) require 'rails/commands'
Ruby
#!/usr/bin/env rake # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require File.expand_path('../config/application', __FILE__) Cupido::Application.load_tasks
Ruby
source 'https://rubygems.org' gem 'rails', '3.2.13' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'sqlite3' # gem 'pg' # Gems used only for assets and not required # in production environments by default. group :assets do gem 'sass-rails', '~> 3.2.3' gem 'coffee-r...
Ruby
class AddAttachmentAvatarToArticles < ActiveRecord::Migration def self.up change_table :articles do |t| t.attachment :avatar end end def self.down drop_attached_file :articles, :avatar end end
Ruby
class DropComboOrder < ActiveRecord::Migration def up drop_table :combo_orders end def down raise ActiveRecord::IrreversibleMigration end end
Ruby
class DropCombo < ActiveRecord::Migration def up drop_table :combos end def down raise ActiveRecord::IrreversibleMigration end end
Ruby
class CreateArticleOrders < ActiveRecord::Migration def change create_table :article_orders do |t| t.integer :article_id t.integer :order_id t.timestamps end end end
Ruby
class CreateComboOrders < ActiveRecord::Migration def change create_table :combo_orders do |t| t.integer :combo_id t.integer :order_id t.timestamps end end end
Ruby
class AddDeviseToUsers < ActiveRecord::Migration def self.up change_table(:users) do |t| ## Database authenticatable #t.string :email, :null => false, :default => "" t.string :encrypted_password, :null => false, :default => "" ## Recoverable t.string :reset_password_t...
Ruby
class CreateCombos < ActiveRecord::Migration def change create_table :combos do |t| t.integer :prize t.timestamps end end end
Ruby
class CreateOrders < ActiveRecord::Migration def change create_table :orders do |t| t.date :delivery_date t.string :street t.string :street_number t.timestamps end end end
Ruby
class CreateEvents < ActiveRecord::Migration def change create_table :events do |t| t.string :name t.date :date t.timestamps end end end
Ruby
class AddAttachmentPictureToArticles < ActiveRecord::Migration def self.up change_table :articles do |t| t.attachment :picture end end def self.down drop_attached_file :articles, :picture end end
Ruby
class CreateCategories < ActiveRecord::Migration def change create_table :categories do |t| t.string :name t.timestamps end end end
Ruby
class DropComboArticles < ActiveRecord::Migration def up drop_table :article_combos end def down raise ActiveRecord::IrreversibleMigration end end
Ruby
class CreateArticleCombos < ActiveRecord::Migration def change create_table :article_combos do |t| t.integer :article_id t.integer :combo_id t.timestamps end end end
Ruby
class CreateUsers < ActiveRecord::Migration def change create_table :users do |t| t.string :name t.string :last_name t.string :email t.string :password t.integer :rol t.timestamps end end end
Ruby
class CreateArticles < ActiveRecord::Migration def change create_table :articles do |t| t.string :name t.integer :prize t.string :picture t.text :description t.integer :category_id t.timestamps end end end
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' }]) # Mayor.create(name: 'Emanuel...
Ruby
# This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) run Cupido::Application
Ruby
ENV["RAILS_ENV"] = "test" require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' class ActiveSupport::TestCase # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. # # Note: You'll currently still have to declare fixtures explicitly in integrati...
Ruby
#coding=UTF-8 file = Dir.new("./Cv_xml") file.each do |path| fork do if path != "." and path != ".." and File.extname(path)== ".xml" sortie = "./Cv_html/#{path.reverse[4, path.size].reverse}.html" File::open(sortie, File::WRONLY | File::CREAT) do |fic_out| STDOUT.reopen(fic_out) syst...
Ruby
#coding=UTF-8 STDOUT.reopen("index.html") system("xsltproc Competences.xsl Competences.xml") type = ["Autre", "Langage", "Methode", "Outil", "Reseau", "SGBD"] type.each do |e| fork do STDOUT.reopen("#{e}.html") system("xsltproc Competences.xsl Competences.xml --stringparam type #{e}") end end
Ruby
#coding=UTF-8 require 'rexml/document' include REXML file = File.new("Competences.xml") doc = Document.new(file) root = doc.root root.each_element do |e| STDOUT.reopen("./html/#{e.elements["@idC"]}.html") system("xsltproc Personnes.xsl Personnes.xml --stringparam idC #{e.elements["@idC"]}") end
Ruby
require 'xml/xslt' xslt = XML::XSLT.new() xslt.xml = "text.xml" xslt.xsl = "test.xsl" out = xslt.serve() print out;
Ruby
#coding=UTF-8 require 'rexml/document' include REXML file = File.new("Competences.xml") doc = Document.new(file) root = doc.root root.each_element do |e| idC = e.elements["@idC"] STDOUT.reopen("./CvCompetence/#{idC}.html") system("xsltproc Personnes.xsl Personnes.xml --stringparam idC #{idC}") end file = D...
Ruby
#coding=UTF-8 require 'rexml/document' include REXML file = [] doc = Document.new(File.new("Personnes.xml")) doc.root.each_element('pers:CV/pers:NomFichier') do |e| file << e.text end file.each do |path| sortie = "../CVsHtml/#{path.reverse[4, path.size].reverse}.html" File::open(sortie, File::WRONLY | File:...
Ruby
module UserSystem CONFIG = { # Source address for user emails :email_from => 'redrover@cs-linux.ubishops.ca', # Destination email for system errors :admin_email => 'redrover@cs-linux.ubishops.ca', # Sent in emails to users :app_url => 'http://localhost:3000/', # Sent in emails to users ...
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 err...
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
# Be sure to restart your web server when you modify this file. # Uncomment below to force Rails into production mode when # you don't control web/app server and can't set it the proper way # ENV['RAILS_ENV'] ||= 'production' # Bootstrap the Rails environment, frameworks, and default configuration require File.join(...
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 =~ /mswin32/ require 'pathname' root_path = Pathname.new(root_path).cleanpath(true).to_s end RAILS...
Ruby
ActionController::Routing::Routes.draw do |map| # Add your own custom routes here. # The priority is based upon order of creation: first created -> highest priority. # Here's a sample route: # map.connect 'products/:id', :controller => 'catalog', :action => 'view' # Keep in mind you can assign values other...
Ruby
# Methods added to this helper will be available to all templates in the application. require 'login_engine' module ApplicationHelper include Localization include LoginEngine end
Ruby
module ImagesHelper end
Ruby
module PhotosHelper end
Ruby
module EditHelper def get_help(topic) begin help = YAML.load(File.open("#{RAILS_ROOT}/doc/help/" + CUPOLA_CONFIG["help_file"]+".yml")) rescue Exception => e "<p> " + "Sorry, a problem has occured with the help system: " + e.message + "</p>" end if !help.nil? and !help[topic].nil? RedCloth...
Ruby
module ReadHelper def link_to_issue (name,issue) link_to name , :controller => "read", :action => "read_issue", :day => issue.date_published.day, :year => issue.date_published.year, :month => issue.date_published.month end def link_to_section(name, section) issue = section.issue link_to name , :controller => ...
Ruby
module EditorHelper end
Ruby
# == Schema Information # Schema version: 36 # # Table name: sections # # id :integer not null, primary key # name :string(255) not null # section_description :string(255) # issue_id :integer not null # created_at :datetime not null # updat...
Ruby
# == Schema Information # Schema version: 36 # # Table name: images # # id :integer not null, primary key # name :string(255) not null # comment :string(255) not null # author :string(255) not null # class Image < ActiveRecord::Base # Class variable to define the versions of every image that...
Ruby
# == Schema Information # Schema version: 36 # # Table name: articles # # id :integer not null, primary key # title :string(255) not null # body :text not null # author :string(255) not null # created_at :datetime not null # updated_at :datetime not null # blur...
Ruby
# == Schema Information # Schema version: 36 # # Table name: volumes # # id :integer not null, primary key # volume_number :integer not null # description :string(255) # created_at :datetime not null # updated_at :datetime not null # # A Volume is a collection of Issues...
Ruby
# == Schema Information # Schema version: 36 # # Table name: issues # # id :integer not null, primary key # issue_number :integer not null # volume_id :integer not null # created_at :datetime not null # updated_at :datetime not null # status :integer ...
Ruby
class PhotosController < ApplicationController def index end def photo @picture = Picture.find(params[:id]) send_data(@picture.data, :filename => @picture.name, :type => @picture.content_type, :disposition => "inline") end end
Ruby
# This controller edits the newspaper's contents # # Workflow: # # 1. The editor logs in. The masthead has a Preferences panel where they can change # account memberships and assorted other preferences. # 2. If there aren't any volumes, they're asked to make one, and they do. # 3. If there aren't any issues, they'...
Ruby
class ImagesController < ApplicationController def view @image = Image.find(params[:id]) @size = params[:size] if !params[:size].nil? and Image.possible_sizes.key? params[:size] end # To get the url of an image an id is neccesarym in the case of image type dragable objects # rails passes the id...
Ruby
class ReadController < ApplicationController def index redirect_to :action => "latest_issue" end def latest_issue @issue = Issue.last_issue_published if !@issue.nil? redirect_to :action => "read_issue", :year => @issue.date_published.year, :month => @issue.date_published.month, :day => @issue...
Ruby
require 'login_engine' # The filters added to this controller will be run for all controllers in the application. # Likewise will all the methods added be available for all controllers. class ApplicationController < ActionController::Base include LoginEngine helper :user model :user end
Ruby
# Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require(File.join(File.dirname(__FILE__), 'config', 'boot')) require 'rake' require 'rake/testtask' require 'rake/rdoctask' require 'tasks/rails'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/breakpointer'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/console'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/runner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/benchmarker'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/benchmarker'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/profiler'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/profiler'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/plugin'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/destroy'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/about'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/environment' require 'rubygems' require_gem 'db_structure' DBStructure::db_structure
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/runner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/breakpointer'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/server'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/generate'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/console'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/environment' require 'rubygems' require_gem 'db_structure' DBStructure::db_structure
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/reaper'
Ruby