code
stringlengths
1
1.73M
language
stringclasses
1 value
module AppsHelper end
Ruby
module CommentsHelper end
Ruby
class Visual < ActiveRecord::Base belongs_to :app has_attached_file :image, :url => "/:attachment/:id/:style/:basename.:extension", :path => ":rails_root/public/:attachment/:id/:style/:basename.:extension" validates_attachment_presence :image validates_attachment_co...
Ruby
class AppPermission < ActiveRecord::Base belongs_to :app belongs_to :permission end
Ruby
class Target < ActiveRecord::Base has_many :app_targets has_many :apps, :through => :app_targets end
Ruby
class Rating < ActiveRecord::Base versioned belongs_to :app end
Ruby
class Comment < ActiveRecord::Base belongs_to :app end
Ruby
class Permission < ActiveRecord::Base validates_uniqueness_of :name validates_presence_of :name has_many :app_permissions has_many :apps, :through => :app_permissions end
Ruby
class App < ActiveRecord::Base validates_uniqueness_of :packageName has_one :rating, :dependent => :destroy has_many :visuals, :dependent => :destroy has_many :comments, :dependent => :destroy has_many :app_targets has_many :targets, :through => :app_targets has_many :app_permissions has_many :...
Ruby
class AppTarget < ActiveRecord::Base belongs_to :app belongs_to :target end
Ruby
class Record attr_accessor :id, :exists end
Ruby
class ApplicationController < ActionController::Base # protect_from_forgery end
Ruby
class AppTargetsController < ApplicationController # POST /app_targets.xml # POST /app_targets.json def create @app_target = AppTarget.new(params[:app_target]) respond_to do |format| if @app_target.save format.xml { render :xml => @app_target, :status => :created, :location => @app_targ...
Ruby
class CommentsController < ApplicationController # POST /comments.xml # POST /comments.json def create @app = App.find(params[:app_id]) @comment = @app.comments.new(params[:comment]) respond_to do |format| if @comment.save format.xml { render :xml => @comment, :status => :...
Ruby
class PermissionsController < ApplicationController # POST /permission.xml # POST /permission.json def create @permission = Permission.new(:name => params[:permission]) respond_to do |format| if @permission.save format.xml { render :xml => @permission, :status => :created, :location => @...
Ruby
class AppsController < ApplicationController # GET /apps # GET /apps.xml # GET /apps.json def index @apps = App.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @apps } format.json { render :json => @apps } end end # GET /apps/1 ...
Ruby
class VisualsController < ApplicationController # POST /visuals def create @app = App.find(params[:app_id]) @visual = @app.visuals.new(:image => params[:image]) respond_to do |format| if @visual.save format.html { render :json => @visual, :status => :created} else ...
Ruby
class AppPermissionsController < ApplicationController # POST /app_permissions/update_permissions.xml # POST /app_permissions/update_permissions.json def update_permissions app = App.find(params[:app_id]) app.permission_ids = params[:permissions] respond_to do |format| if app.save! ...
Ruby
# Be sure to restart your server when you modify this file. # Add new inflection rules using the following format # (all these examples are active by default): # ActiveSupport::Inflector.inflections do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person', ...
Ruby
# Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } # You can also remove all the silencers if you're trying to debug a probl...
Ruby
VestalVersions.configure do |config| # Place any global options here. For example, in order to specify your own version model to use # throughout the application, simply specify: # # config.class_name = "MyCustomVersion" # # Any options passed to the "versioned" method in the model itself will override this...
Ruby
# Be sure to restart your server when you modify this file. # Your secret key for verifying the integrity of signed cookies. # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attac...
Ruby
# Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf # Mime::Type.register_alias "text/html", :iphone
Ruby
# Be sure to restart your server when you modify this file. Marketplace::Application.config.session_store :cookie_store, :key => '_Marketplace_session' # Use the database for sessions instead of the cookie-based default, # which shouldn't be used to store highly confidential information # (create the session table wi...
Ruby
Marketplace::Application.routes.draw do root :to => "apps#index" resources :apps do collection do post 'exists', 'ids' end resources :visuals do collection do post 'exists' end end end resources :app_targets do collection do post 'exists' end end ...
Ruby
require 'rubygems' # Set up gems listed in the Gemfile. gemfile = File.expand_path('../../Gemfile', __FILE__) begin ENV['BUNDLE_GEMFILE'] = gemfile require 'bundler' Bundler.setup rescue Bundler::GemNotFound => e STDERR.puts e.message STDERR.puts "Try running `bundle install`." exit! end if File.exist?(gem...
Ruby
require File.expand_path('../boot', __FILE__) require 'rails/all' # If you have a Gemfile, require the gems listed there, including any gems # you've limited to :test, :development, or :production. Bundler.require(:default, Rails.env) if defined?(Bundler) module Marketplace class Application < Rails::Application ...
Ruby
# Load the rails application require File.expand_path('../application', __FILE__) # Initialize the rails application Marketplace::Application.initialize!
Ruby
Marketplace::Application.configure do # Settings specified here will take precedence over those in config/application.rb # The production environment is meant for finished, "live" apps. # Code is not reloaded between requests config.cache_classes = true # Full error reports are disabled and caching is turne...
Ruby
Marketplace::Application.configure do # Settings specified here will take precedence over those in config/application.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 w...
Ruby
Marketplace::Application.configure do # Settings specified here will take precedence over those in config/application.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 t...
Ruby
# This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) run Marketplace::Application
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.expand_path('../config/application', __FILE__) require 'rake' Marketplace::Application.load_tasks
Ruby
# Be sure to restart your server when you modify this file. # Add new inflection rules using the following format # (all these examples are active by default): # ActiveSupport::Inflector.inflections do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person',...
Ruby
# Be sure to restart your server when you modify this file. # These settings change the behavior of Rails 2 apps and will be defaults # for Rails 3. You can remove this initializer when Rails 3 is released. if defined?(ActiveRecord) # Include Active Record class name as root for JSON serialized output. ActiveReco...
Ruby
# Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf # Mime::Type.register_alias "text/html", :iphone
Ruby
# Be sure to restart your server when you modify this file. # Your secret key for verifying cookie session data integrity. # If you change this key, all old sessions will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. Act...
Ruby
# Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } # You can also remove all the silencers if you're trying do debug a probl...
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 # Full error reports are disabled and caching is turned on config.action_controller.consider_all_reque...
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 server when you modify this file # Specifies gem version of Rails to use when vendor/rails is not present RAILS_GEM_VERSION = '2.3.4' unless defined? RAILS_GEM_VERSION # Bootstrap the Rails environment, frameworks, and default configuration require File.join(File.dirname(__FILE__), 'boot') ...
Ruby
# Don't change this file! # Configure your app in config/environment.rb and config/environments/*.rb RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) module Rails class << self def boot! unless booted? preinitialize pick_boot.run end end def booted? ...
Ruby
ActionController::Routing::Routes.draw do |map| map.resources :documents map.resources :invoices map.resources :contractors map.resources :products map.resources :warehouses map.resources :transactors map.resources :employees # The priority is based upon order of creation: first created -> highe...
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper end
Ruby
module DocumentsPositionsHelper end
Ruby
module InvoicesHelper end
Ruby
module WarehousePositionsHelper end
Ruby
module ContractorsHelper end
Ruby
module DocumentsHelper end
Ruby
module ProductsHelper end
Ruby
module TransactorsHelper end
Ruby
module WarehousesHelper end
Ruby
module EmployeesHelper end
Ruby
class WarehousePosition < ActiveRecord::Base belongs_to :warehouse belongs_to :product end
Ruby
class Transactor < ActiveRecord::Base has_many :documents, :foreign_key => "source_id" has_many :documents, :foreign_key => "target_id" end
Ruby
require 'digest/sha1' class Employee < ActiveRecord::Base belongs_to :warehouse has_many :documents validates_presence_of :name, :surname, :address, :login, :password, :warehouse_id validates_length_of :name, :minimum => 2 validates_length_of :surname, :minimum => 2 validates_length_of :login,...
Ruby
class Contractor < Transactor end
Ruby
class Product < ActiveRecord::Base has_many :warehouse_positions has_many :warehouses, :through => :warehouse_positions has_many :documents_positions has_many :documents, :through => :documents_positions validates_presence_of :name, :code, :unit, :net_price, :vat_rate validates_uniqueness_of :name...
Ruby
class Invoice < Document has_many :corrective_invoices, :class_name => "Invoice", :foreign_key => :corrected_invoice_id belongs_to :corrected_invoice, :class_name => "Invoice", :foreign_key => :corrected_invoice_id validates_presence_of :selling_date, :due_date, :payment_method validates_inclusion_of :payme...
Ruby
class Warehouse < Transactor has_many :positions, :class_name => "WarehousePosition", :dependent => :destroy has_many :products, :through => :positions has_many :employees end
Ruby
class DocumentsPosition < ActiveRecord::Base belongs_to :product belongs_to :document end
Ruby
class Document < ActiveRecord::Base belongs_to :source, :class_name => "Transactor", :foreign_key => "source_id" belongs_to :target, :class_name => "Transactor", :foreign_key => "target_id" belongs_to :employee has_many :positions, :class_name => "DocumentsPosition", :dependent => :destroy has_...
Ruby
class EmployeesController < ApplicationController # GET /employees # GET /employees.xml before_filter :login_required before_filter :session_expiry def index @employees = Employee.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @employees...
Ruby
class HomeController < ApplicationController before_filter :login_required before_filter :session_expiry def index respond_to do |format| format.html # index.html.erb format.xml # { render :xml => @invoices } end end end
Ruby
class ProductsController < ApplicationController # GET /products # GET /products.xml before_filter :login_required before_filter :session_expiry def index @products = Product.paginate :page => params[:page], :per_page => 10, :order => 'name' respond_to do |format| format.html # index.html...
Ruby
class WarehousesController < ApplicationController # GET /warehouses # GET /warehouses.xml before_filter :login_required before_filter :session_expiry private def set_positions_from_cookie position_strings = cookies[:positions].split(',') position_strings.each do |position_string| position_dat...
Ruby
class TransactorsController < ApplicationController # GET /transactors # GET /transactors.xml before_filter :login_required before_filter :session_expiry def index @transactors = Transactor.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @transac...
Ruby
class DocumentsController < ApplicationController # GET /documents # GET /documents.xml before_filter :session_expiry before_filter :login_required private def set_positions_from_cookie position_strings = cookies[:positions].split(',') position_strings.each do |position_string| position_data = po...
Ruby
class SecurityController < ApplicationController layout 'standard' def login case request.method when :post if session['employee'] = Employee.authenticate(params['employee_login'], params['employee_password']) flash['notice'] = "Login successful" redirect_back_or_default :c...
Ruby
# Filters added to this controller apply to all controllers in the application. # Likewise, all the methods added will be available for all controllers. require_dependency "login_system" class ApplicationController < ActionController::Base include LoginSystem layout 'standard' # require_dependency "employee" he...
Ruby
class ContractorsController < ApplicationController # GET /contractors # GET /contractors.xml before_filter :session_expiry before_filter :login_required def index @contractors = Contractor.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @contractor...
Ruby
class InvoicesController < ApplicationController # GET /invoices # GET /invoices.xml before_filter :login_required before_filter :session_expiry private def set_positions_from_cookie position_strings = cookies[:positions].split(',') position_strings.each do |position_string| position_data = posit...
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.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/runner'
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/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/profiler'
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/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/dbconsole'
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/console'
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/generate'
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__) $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/plugin'
Ruby
class CreateDocuments < ActiveRecord::Migration def self.up create_table :documents do |t| #common atributes t.datetime :issue_date, :null => false t.string :document_type, :null => false t.string :number, :null => false t.integer :source_id, :null => false t.integer :target_id, :null => f...
Ruby
class CreateEmployees < ActiveRecord::Migration def self.up create_table :employees do |t| t.string :name, :null => false t.string :surname, :null => false t.string :address, :null => false t.string :login, :null => false t.string :password, :null => false t.integer :warehouse_id...
Ruby
class CreateTransactors < ActiveRecord::Migration def self.up create_table :transactors do |t| #common attributes t.string :name, :null => false t.string :street, :null => false t.string :city, :null => false t.string :postal_code, :null => false t.string :country, :null => false ...
Ruby
class CreateProducts < ActiveRecord::Migration def self.up create_table :products do |t| t.string :name, :null => false t.string :code, :null => false t.string :pkwiu t.string :unit, :null => false t.decimal :net_price, :null => false t.decimal :vat_rate, :null => false ...
Ruby
class CreateWarehousePositions < ActiveRecord::Migration def self.up create_table :warehouse_positions do |t| t.integer :warehouse_id t.integer :product_id t.float :quantity t.timestamps end end def self.down drop_table :warehouse_positions end end
Ruby
class CreateDocumentsPositions < ActiveRecord::Migration def self.up create_table :documents_positions do |t| t.float :quantity, :null => false t.integer :document_id t.integer :product_id t.timestamps end end def self.down drop_table :documents_positions end end
Ruby