code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
class NotificationsController < ApplicationController
# GET /notifications
# GET /notifications.json
def index
@notification = Notification.find_by_account_id_and_read params[:account_id], false
if @notification != nil
@notification.read = true
respond_to do |format|
@notification.sav... | Ruby |
class StubpaymentsController < ApplicationController
def index
end
def payment
#flash[:status] = "Payment approved"
#redirect_to stubpayments_url
hash = { :account_id => '508aa24fe4b096f709727535', :amount => params[:amount], :category_id => params[:category][:id] }
myhash = {:payment => hash}
... | Ruby |
class CategoriesController < ApplicationController
# GET /categories
# GET /categories.json
def index
@categories = Category.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @categories }
end
end
# GET /categories/1
# GET /categories/1.json
def s... | Ruby |
class AccountBudgetRulesController < ApplicationController
# GET /account_budget_rules
# GET /account_budget_rules.json
def index
a= params[:account_id]
@account_budget_rules = {:categories => AccountBudgetRule.find_by_sql("select name as category, budget_limit, ifnull(utilization,0) as utilization fr... | Ruby |
class ApplicationController < ActionController::Base
protect_from_forgery
end
| Ruby |
class BudgetExceptionsController < ApplicationController
# GET /budget_exceptions
# GET /budget_exceptions.json
def index
if (!params[:account_id].nil?) then
budget_exception = BudgetException.new
budget_exception.account_id= params[:account_id]
budget_exception.amount = params[:amount]
... | 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__)
BudgetGroup::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__)
BudgetGroup::Application.load_tasks
| Ruby |
source 'http://rubygems.org'
gem 'rails', '3.1.1'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.1.4'
gem 'coffee-rails', '~... | Ruby |
class RemoveAccountBudgetView < ActiveRecord::Migration
def up
execute <<-SQL
drop VIEW my_view
SQL
end
end | Ruby |
class CreatePayments < ActiveRecord::Migration
def change
create_table :payments do |t|
t.integer :account_id
t.integer :commerce_id
t.float :amount
t.references :category
t.timestamps
end
add_index :payments, :category_id
end
end
| Ruby |
class CreateBudgetExceptions < ActiveRecord::Migration
def change
create_table :budget_exceptions do |t|
t.integer :account_id
t.date :month
t.references :category
t.integer :authorizer_id
t.timestamps
end
add_index :budget_exceptions, :category_id
end
end
| Ruby |
class AddPriceToNotifications < ActiveRecord::Migration
def change
add_column :notifications, :price, :float
end
end
| Ruby |
class ChangeAccountIdToString < ActiveRecord::Migration
def up
remove_column :budgets, :account_id
add_column :budgets, :account_id, :string
end
def down
end
end
| Ruby |
class CreateAccountBudgetView < ActiveRecord::Migration
def up
execute <<-SQL
CREATE VIEW my_view AS SELECT * from budgets
SQL
end
def down
execute <<-SQL
DROP VIEW my_view
SQL
end
end
| Ruby |
class AddAccountBudgetView < ActiveRecord::Migration
def up
execute <<-SQL
CREATE VIEW "account_budget_rules" AS
select a.id, a.account_id, a.name, a.budget_limit,a.utilization, a.budget_limit + ifnull(sum(e.amount),0) as "budget_limit_w_exceptions" from (
SELECT 1 as "id", b.account_id, c.name as "name" ,b.amo... | Ruby |
class CreateNotifications < ActiveRecord::Migration
def change
create_table :notifications do |t|
t.references :category
t.float :amount
t.string :account_id
t.boolean :read
t.timestamps
end
add_index :notifications, :category_id
end
end
| Ruby |
class DeviseCreateUsers < ActiveRecord::Migration
def change
create_table(:users) do |t|
## Database authenticatable
t.string :email, :null => false, :default => ""
t.string :encrypted_password, :null => false, :default => ""
## Recoverable
t.string :reset_password_to... | Ruby |
class ChangeAccountIdToStringInPayment < ActiveRecord::Migration
def up
remove_column :payments, :account_id
add_column :payments, :account_id, :string
remove_column :payments, :commerce_id
add_column :payments, :commerce_id, :string
end
def down
end
end
| Ruby |
class CreateCategories < ActiveRecord::Migration
def change
create_table :categories do |t|
t.string :name
t.timestamps
end
end
end
| Ruby |
class AddAmountToBudgetExceptions < ActiveRecord::Migration
def change
add_column :budget_exceptions, :amount, :float
end
end
| Ruby |
class CreateBudgets < ActiveRecord::Migration
def change
create_table :budgets do |t|
t.integer :account_id
t.references :category
t.float :amount
t.timestamps
end
add_index :budgets, :category_id
end
end
| Ruby |
class FixBudgetException < ActiveRecord::Migration
def up
remove_column :budget_exceptions, :account_id
add_column :budget_exceptions, :account_id, :string
remove_column :budget_exceptions, :authorizer_id
remove_column :budget_exceptions, :month
end
def down
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 BudgetGroup::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 |
# This file registers the sencha-touch framework with compass
# It's a magic name that compass knows how to find.
dir = File.dirname(__FILE__)
require File.join(dir, 'lib', 'theme_images.rb')
# Include compass-recipes
require File.join(File.dirname(__FILE__), 'vendor', 'compass-recipes', 'config')
Compass::BrowserSup... | Ruby |
module SenchaTouch
module SassExtensions
module Functions
module ThemeImages
def theme_image(theme, path, mime_type = nil)
path = path.value
images_path = File.join(File.dirname(__FILE__), "..", "images", theme.value)
real_path = File.join(images_path, path)
i... | Ruby |
stylesheet 'sencha-touch.scss' | Ruby |
# Get the directory that this configuration file exists in
dir = File.dirname(__FILE__)
# Load the sencha-touch framework automatically.
load File.join(dir, '..', 'themes')
# Compass configurations
fonts_path = File.join(dir, '..', 'themes/fonts/')
sass_path = dir
css_path = File.join(dir, "..", "css")
environment =... | Ruby |
# Get the directory that this configuration file exists in
dir = File.dirname(__FILE__)
# Load the sencha-touch framework automatically.
load File.join(dir, '..', 'themes')
# Compass configurations
sass_path = dir
css_path = File.join(dir, "..", "css-debug")
fonts_path = File.join(dir, '..', 'themes/fonts/')... | Ruby |
# Get the directory that this configuration file exists in
dir = File.dirname(__FILE__)
# Load the sencha-touch framework automatically.
load File.join(dir, '..', '..', 'touch', 'resources', 'themes')
# Compass configurations
sass_path = dir
css_path = File.join(dir, "..", "css")
# Require any additional compass plu... | Ruby |
require 'digest/md5'
require 'open-uri'
require 'rexml/document'
require 'cgi'
def remove_newline(s)
return s.gsub("\n", "")
end
def save_map(filename, map, sp)
File.open(filename, 'w') do |f|
map.each do |k, v|
f.write("#{k}#{sp}#{v}\n")
end
end
end
def load_map(filename, sp)
map = Hash.new
... | Ruby |
#!/usr/bin/env ruby
# Copyright 2010, Lloyd Hilaiel.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and t... | Ruby |
#!/usr/bin/env ruby
# encoding: utf-8
# ruby version of Unicode table converter
require 'rubygems'
begin
require 'bundler/setup'
rescue LoadError
puts "You should install Bundler using 'gem install bundler' and run 'bundle install'"
end
require 'yajl'
require 'fastercsv'
## These four elements are also valid in... | Ruby |
source :rubygems
gem 'yajl-ruby', '>= 0.7.8'
gem 'fastercsv', :platforms => :ruby_18
| Ruby |
#!/usr/bin/env ruby
# encoding: utf-8
# ruby version of Unicode table converter
require 'rubygems'
begin
require 'bundler/setup'
rescue LoadError
puts "You should install Bundler using 'gem install bundler' and run 'bundle install'"
end
require 'yajl'
require 'fastercsv'
## These four elements are also valid in... | Ruby |
require 'yaml'
require 'fileutils'
task :default => :build
# desc 'Package the library and create both compressed and uncompressed versions. Process the result with jslint'
# task :build => [:prepare, :package_include, :minify, :lint] do
# puts "Building #{fetch_options['name']}"
# end
#
task :build => [:prepare, :... | Ruby |
class CreateUsers < ActiveRecord::Migration
def up
create_table :users do |t|
t.string :profile_id
t.string :email
t.string :refresh_token
end
add_index :users, :profile_id
end
def down
drop_table :users
end
end
| Ruby |
# Copyright (C) 2012 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | Ruby |
source :gemcutter
gem 'sinatra', :require => 'sinatra/base'
gem 'thin', '~> 1.3'
gem 'pg'
gem 'sinatra-activerecord'
gem 'google-api-client', '>= 0.4.4', :require => 'google/api_client'
group :development do
gem 'rake'
gem 'sqlite3-ruby'
end
| Ruby |
require 'sinatra.rb'
# Sinatra defines #set at the top level as a way to set application configuration
set :run, false
set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development)
require './main'
run Sinatra::Application | Ruby |
require 'sinatra/activerecord/rake'
require './main' | Ruby |
#!/usr/bin/env ruby
require 'rubygems'
require 'mqtt'
MQTT::Client.connect('localhost',1883) do |client|
client.get('#') do |topic,message|
puts "#{topic}: #{message}"
end
end
| 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.
# 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 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.
#
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters ... | Ruby |
# Be sure to restart your server when you modify this file.
Apsoo::Application.config.session_store :cookie_store, key: '_apsoo_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 with "rails gener... | 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 |
Apsoo::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
config.action_c... | Ruby |
Apsoo::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 web serv... | Ruby |
Apsoo::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 test suit... | Ruby |
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
Apsoo::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 |
Apsoo::Application.routes.draw do
get "requisicao/index"
get "requisicao/show"
get "requisicao/new"
get "requisicao/edit"
get "requisicao/destroy"
get "requisicaos_controller/index"
get "requisicaos_controller/show"
get "requisicaos_controller/new"
get "requisicaos_controller/edit"
get "requisicao... | Ruby |
module ApplicationHelper
end
| Ruby |
module UsuariosHelper
end
| Ruby |
module RequisicaoHelper
end
| Ruby |
module TipoQuartosHelper
end
| Ruby |
module ConsultasHelper
end
| Ruby |
module RequisicaosControllerHelper
end
| Ruby |
module SessionsHelper
end
| Ruby |
module HospedagemsHelper
end
| Ruby |
module HomeHelper
end
| Ruby |
module RequisicaosHelper
end
| Ruby |
module ReservasHelper
end
| Ruby |
module QuartosHelper
end
| Ruby |
module ServicosHelper
end
| Ruby |
class Funcionario < Usuario
has_many :reservas
has_many :hospedagems
end
| Ruby |
class Estado < ActiveRecord::Base
attr_accessible :nome, :sigla
end
| Ruby |
class Gerente < Funcionario
end
| Ruby |
class Requisicao < ActiveRecord::Base
belongs_to :hospedagem
belongs_to :servico
attr_accessible :estornado, :preco_unitario, :qtd, :hospedagem_id, :servico_id
validates_presence_of :hospedagem_id, :servico_id, :qtd
validates_inclusion_of :estornado, :in => [true, false]
validates_numericality_of :qtd
b... | Ruby |
class Usuario < ActiveRecord::Base
attr_accessible :apt, :bairro, :cidade, :estado, :login, :nome, :numero, :rua, :senha, :telefone, :senha_confirmation, :type
before_save :criptografa_senha
validates_presence_of :login
validates_presence_of :nome
validates_presence_of :senha, :on => :create
validates_co... | Ruby |
class Admin < Usuario
end
| Ruby |
class Servico < ActiveRecord::Base
has_many :hospedagems, :through => :requisicaos
has_many :requisicaos
attr_accessible :desc_curta, :desc_longa, :preco
validates_presence_of :desc_curta
validates_presence_of :desc_longa
validates_presence_of :preco
validates_numericality_of :preco
end
| Ruby |
class Quarto < ActiveRecord::Base
belongs_to :tipo_quarto, :autosave => true
has_many :hospedagems
attr_accessible :numero, :reference
end
| Ruby |
class TipoQuarto < ActiveRecord::Base
attr_accessible :descricao, :preco_diaria
has_many :quartos
validates_numericality_of :preco_diaria
end
| Ruby |
class Reserva < ActiveRecord::Base
attr_accessible :data_encerramento, :data_entrada_hospedagem, :data_saida_hospedagem, :quarto_id, :hospede_id, :funcionario_id
belongs_to :funcionario
belongs_to :hospede
belongs_to :quarto
validates_presence_of :data_entrada_hospedagem, :data_saida_hospedagem
validates_... | Ruby |
class Hospede < Usuario
has_many :reservas
has_many :hospedagems
def hospedagem_atual
hospedagems.where("data_encerramento IS NULL").first
end
def reserva_atual
reservas.where("data_encerramento IS NULL").first
end
end
| Ruby |
class Hospedagem < ActiveRecord::Base
belongs_to :hospede
belongs_to :funcionario
belongs_to :quarto
has_many :servicos, :through => :requisicaos
has_many :requisicaos
attr_accessible :data_encerramento, :aberta
def status
if self.aberta
"Aberta"
else
"Encerrada"
end
end
def durac... | Ruby |
class HomeController < ApplicationController
def index
end
end
| Ruby |
class RequisicaosController < ApplicationController
before_filter :autoriza_admin, :only => [:edit, :update, :destroy]
# GET /requisicaos
# GET /requisicaos.json
def index
if params[:hospedagem_id]
@requisicaos = Requisicao.where("hospedagem_id = ?", params[:hospedagem_id])
else
@requisicaos... | Ruby |
class ReservasController < ApplicationController
# GET /reservas
# GET /reservas.json
def index
@reservas = Reserva.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @reservas }
end
end
# GET /reservas/1
# GET /reservas/1.json
def show
@reserv... | Ruby |
class ConsultasController < ApplicationController
def index
end
# OK
def taxa_ocupacao
if params[:data_busca]
data = Date.civil(params[:data_busca][:year].to_i, params[:data_busca][:month].to_i, params[:data_busca][:day].to_i)
data = data.to_datetime
quartos_ocupados = Hospedagem.where("created_... | Ruby |
class UsuariosController < ApplicationController
before_filter :autoriza_hospede, :only => [:show, :edit, :update]
before_filter :autoriza_admin, :except => [:show, :edit, :update, :new]
# GET /usuarios
# GET /usuarios.json
def index
if current_user.type == "Admin"
@usuarios = Usuario.all
elsif... | Ruby |
class TipoQuartosController < ApplicationController
def index
@tipo_quartos = TipoQuarto.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @tipo_quartos }
end
end
def show
@tipo_quarto = TipoQuarto.find(params[:id])
respond_to do |format|
format.html... | Ruby |
class SessionsController < ApplicationController
def new
end
def create
usuario = Usuario.autentica(params[:login], params[:senha])
if usuario
session[:usuario_id] = usuario.id
redirect_to root_url
else
flash.now.alert = "Login ou senha invalida"
render "new"
end
end
def destroy
session[:usu... | Ruby |
class ServicosController < ApplicationController
before_filter :autoriza_admin, :only => [:new, :create, :edit, :update, :destroy]
# GET /servicos
# GET /servicos.json
def index
@servicos = Servico.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @servicos... | Ruby |
class QuartosController < ApplicationController
# GET /quartos
# GET /quartos.json
def index
@quartos = Quarto.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @quartos }
end
end
# GET /quartos/1
# GET /quartos/1.json
def show
@quarto = Quart... | Ruby |
class ApplicationController < ActionController::Base
protect_from_forgery
helper_method :current_user
def current_user
@current_user ||= Usuario.find(session[:usuario_id]) if session[:usuario_id]
end
private
def get_user_options
if @current_user.type == 'Admin'
@user_options = [['Usuarios',... | Ruby |
class HospedagemsController < ApplicationController
before_filter :autoriza_admin, :except => [:show]
# GET /hospedagems
# GET /hospedagems.json
def index
@hospedagems = Hospedagem.abertas
respond_to do |format|
format.html # index.html.erb
format.json { render json: @hospedagems }
end
... | 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__)
Apsoo::Application.load_tasks
| 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__)
Apsoo::Application.load_tasks
| Ruby |
source 'https://rubygems.org'
gem 'rails', '3.2.3'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
#gem 'pg'
gem 'bcrypt-ruby', :require => 'bcrypt'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass... | Ruby |
class CreateTipoQuartos < ActiveRecord::Migration
def change
create_table :tipo_quartos do |t|
t.string :descricao
t.float :preco_diaria
t.timestamps
end
end
end
| Ruby |
class AdicionaEstornoServico < ActiveRecord::Migration
def up
change_table :hospedagems_servicos do |t|
t.boolean :estornado
end
end
def down
change_table :hospedagems_servicos do |t|
t.remove :estornado
end
end
end
| Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.