code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
class CreateCountries < ActiveRecord::Migration
def self.up
create_table :countries do |t|
t.string :name
t.string :abbreviation
t.integer :continent_id
t.timestamps
end
end
def self.down
drop_table :countries
end
end
| Ruby |
class CreateContinents < ActiveRecord::Migration
def self.up
create_table :continents do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :continents
end
end
| Ruby |
class DataComments < ActiveRecord::Migration
def self.up
# Vidage préalable de la table
down
# Création des pays
Comment.create (:title => 'Belle photo!',
:text => 'J étais au même endroit',
:picture_id => '1',
:user_id => '3')
Comment... | Ruby |
class CreateComments < ActiveRecord::Migration
def self.up
create_table :comments do |t|
t.string :title
t.string :text
t.integer :picture_id
t.integer :user_id
t.timestamps
end
end
def self.down
drop_table :comments
end
end
| Ruby |
class DataUsers < ActiveRecord::Migration
def self.up
# Vidage préalable de la table
down
# Création des pays
execute "INSERT INTO users (id, login, email, crypted_password, salt, firstName, name, status)
VALUES ('1', 'admin', 'jean-luc.michelot@bluewin.ch', '07204fd843bb8f7e89116720fd... | Ruby |
class CreateAlbums < ActiveRecord::Migration
def self.up
create_table :albums do |t|
t.string :title
t.string :description
t.integer :country_id
t.timestamps
end
end
def self.down
drop_table :albums
end
end
| Ruby |
class DataAssociations < ActiveRecord::Migration
def self.up
# Vidage préalable de la table
down
# Insertion des données dans la table
Association.create (:picture_id => '1',:album_id => '1')
Association.create (:picture_id => '2',:album_id => '1')
Association.create (:picture_id => '3',:album_i... | Ruby |
class CreatePictures < ActiveRecord::Migration
def self.up
create_table :pictures do |t|
t.string :title
t.string :description
t.string :extension
t.integer :user_id
t.timestamps
end
end
def self.down
drop_table :pictures
end
end
| Ruby |
class DataCountry < ActiveRecord::Migration
def self.up
# Vidage préalable de la table
down
# Création des pays
Country.create (:name => 'Afghanistan', :abbreviation => 'af', :continent_id => '3')
Country.create (:name => 'Afrique du Sud', :abbreviation => 'za', :continent_id => '2')
Country.cre... | Ruby |
class DataPictures < ActiveRecord::Migration
def self.up
# Vidage préalable de la table
down
# Création des pays
Picture.create (:title => 'Vue des toits', :description => 'Superbe photo prise depuis un toit', :extension => 'jpg', :user_id => '2')
Picture.create (:title => 'Maison', :descriptio... | Ruby |
class DataContinent < ActiveRecord::Migration
def self.up
# Vidage préalable de la table
down
# Création des pays
Continent.create (:name => 'Europe')
Continent.create (:name => 'Afrique')
Continent.create (:name => 'Asie')
Continent.create (:name => 'Océanie')
Continent.create (:n... | Ruby |
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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/dispat... | Ruby |
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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 Fast... | Ruby |
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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/dispat... | Ruby |
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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/dispat... | Ruby |
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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 Fast... | Ruby |
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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/dispat... | 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'
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'commands/about' | 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/runner'
| 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/destroy'
| 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/console'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/dbconsole'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'commands/about' | 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/dbconsole'
| 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/plugin'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/spawner'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/spawner'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/inspector'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/reaper'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/reaper'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/inspector'
| 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/request'
| 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/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/request'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/generate'
| Ruby |
require 'enum/enum_adapter'
require 'enum/mysql_adapter' if defined? ActiveRecord::ConnectionAdapters::MysqlAdapter
require 'enum/postgresql_adapter' if defined? ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
require 'enum/sqlite3_adapter' if defined? ActiveRecord::ConnectionAdapters::SQLite3Adapter
require 'enum/... | Ruby |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
end
| Ruby |
module PicturesHelper
end
| Ruby |
module ContinentsHelper
end
| Ruby |
module CountriesHelper
end
| Ruby |
module SessionsHelper
end | Ruby |
module UsersHelper
end | Ruby |
module AlbumsHelper
end
| Ruby |
module CommentsHelper
end
| Ruby |
class Association < ActiveRecord::Base
end
| Ruby |
class DataFile < ActiveRecord::Base
def self.save(upload, extension, id)
directory = "public/images/pictures"
name = id.to_s + "." + extension
nameSmall = id.to_s + "-small."+extension
# create the file path
path = File.join(directory, name)
pathSmall = File.join(directory, nam... | Ruby |
class Continent < ActiveRecord::Base
validates_presence_of :name
has_one :country
end
| Ruby |
class Comment < ActiveRecord::Base
# -----------------------------------------------------------------
# Associations
# -----------------------------------------------------------------
# Un commentaire est posté par un utilisateur
belongs_to :user
# Un commentaire concerne une image
belongs_to :picture
e... | Ruby |
require 'digest/sha1'
class User < ActiveRecord::Base
# Un utilisateur poste plusieurs commentaires
has_many :comment
# Virtual attribute for the unencrypted password
attr_accessor :password
validates_presence_of :login, :email
validates_presence_of :password, :if => :passwor... | Ruby |
class Picture < ActiveRecord::Base
# -----------------------------------------------------------------
# Association
# -----------------------------------------------------------------
# une image est visible dans plusieurs albums
has_and_belongs_to_many :album, :join_table => 'associations'
# Une image con... | Ruby |
class Album < ActiveRecord::Base
# -----------------------------------------------------------------
# Associations
# -----------------------------------------------------------------
# un album contient plusieurs images
has_and_belongs_to_many :picture, :join_table => 'associations'
# un album concerne un ... | Ruby |
class Country < ActiveRecord::Base
# -----------------------------------------------------------------
# Contraintes
# -----------------------------------------------------------------
# Il doit obligatoirement y avoir un nom
validates_presence_of :name
# Chaque nom est unique
validates_uniqueness_of :name... | Ruby |
class CountryrController < ApplicationController
include AuthenticatedSystem
# GET /countryr
# GET /countryr.xml
def index
@liste_continent = Continent.find :all, :order=>"name asc"
@liste_pays = Country.find :all, :order=>"name asc"
@country = Country.find :all
end
#-------------------... | Ruby |
class CommentsController < ApplicationController
include AuthenticatedSystem
before_filter :login_required
# GET /comments
# GET /comments.xml
def index
# Si l'acteur connecté est un administrateur
if isAdmin?()
@comments = Comment.find(:all)
@isAdmin = true
else
# Si l... | Ruby |
class AlbumsController < ApplicationController
include AuthenticatedSystem
before_filter :login_required
#---------------------------------------------------------------------------------------------------------
# INDEX
# GET /albums
# GET /albums.xml
#----------------------------------------------... | Ruby |
require 'rubygems'
require 'RMagick'
class PicturesController < ApplicationController
include AuthenticatedSystem
#before_filter :login_required, only => [:index, :new, :edit, :create, :udpate, :destroy]
before_filter :login_required, :except => [:show]
#before_filter :admin_required, :only => [:edit]
... | Ruby |
class UsersController < ApplicationController
# Be sure to include AuthenticationSystem in Application Controller instead
include AuthenticatedSystem
def index
@users = User.find(:all, :order => 'login')
end
# render new.rhtml
def new
end
def edit
@user = User.find(current_user.id)
end
... | Ruby |
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
include AuthenticatedSystem
# See ActionController::Reques... | Ruby |
class CountriesController < ApplicationController
# GET /countries
# GET /countries.xml
def index
@countries = Country.find(:all)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @countries }
end
end
# GET /countries/new
# GET /countries/new.xml
de... | Ruby |
class ContinentsController < ApplicationController
include AuthenticatedSystem
#before_filter :login_required
#before_filter :admin_required, :only => [:edit]
# GET /continents
# GET /continents.xml
def index
@continents = Continent.find(:all)
respond_to do |format|
format.html # index.html.... | Ruby |
# This controller handles the login/logout function of the site.
class SessionsController < ApplicationController
# Be sure to include AuthenticationSystem in Application Controller instead
include AuthenticatedSystem
# render new.rhtml
def new
end
def create
self.current_user = User.authenticate(pa... | 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 |
# 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.
ActiveRecord::Base.include_root_in_json = true
# Store the full clas... | 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 |
ActionController::Routing::Routes.draw do |map|
map.resources :users
map.resource :session
map.resources :pictures
map.resources :comments
map.resources :users
map.resources :albums
map.resources :countries
map.resources :countries
map.resources :continents
map.resources :continents
map.... | 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 |
# Be sure to restart your 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'
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.2... | 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
# Enable threaded mode
# config.threadsafe!
# Use a different logger for distributed setups
# config.... | 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 |
# 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 |
# Ruby task file
#
# Run with
#
# rake copy_couch_db_binary
desc "Recursively copy build files from ~/src/CouchDb into CouchDBX for inclusion in app"
task :copy_couch_db_binary do
source_dir = File.expand_path("~/src/CouchDb")
raise "The source directory is missing: '#{source_dir}'" unless File.exists?(source_di... | Ruby |
f=File.open('out.txt','w');f.write(%w(s=File.read("out.txt");s="f=File.open('out.txt','w');f.write(%w("+s+")[0]);f.close\n"+s+"\n";f=File.open('out.txt','w');f.write(s);f.close)[0]);f.close
s=File.read("out.txt");s="f=File.open('out.txt','w');f.write(%w("+s+")[0]);f.close\n"+s+"\n";f=File.open('out.txt','w');f.write(s)... | 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 =>... | Ruby |
class DefaultTrialsAndTravails < ActiveRecord::Migration
def self.up
TrialsAndTravails.delete_all
TrialsAndTravails.create(:name => 'The Hand of War')
TrialsAndTravails.create(:name => 'Press-Ganged')
TrialsAndTravails.create(:name => 'Calamity')
TrialsAndTravails.create(:name => 'Ship-Lorn')... | Ruby |
class DefaultRoles < ActiveRecord::Migration
def self.up
Role.delete_all
Role.create(:name => 'Admin')
Role.create(:name => 'Registered')
Role.create(:name => 'Guest')
end
def self.down
Role.delete_all
end
end
| Ruby |
class AddGenderToCharacters < ActiveRecord::Migration
def self.up
add_column :characters, :gender, :string
end
def self.down
remove_column :characters, :gender
end
end
| Ruby |
class AddRoleIdToUsers < ActiveRecord::Migration
def self.up
add_column :users, :role_id, :integer, :default => Role.find_by_name("Registered").id
end
def self.down
remove_column :users, :role_id
end
end
| Ruby |
class AddUsernameToUsers < ActiveRecord::Migration
def self.up
add_column :users, :username, :string
end
def self.down
remove_column :users, :username
end
end
| Ruby |
class DefaultCareers < ActiveRecord::Migration
def self.up
Career.delete_all
Career.create(:name => 'Astropath Transcendent')
Career.create(:name => 'Arch-Militant')
Career.create(:name => 'Void-Master')
Career.create(:name => 'Explorator')
Career.create(:name => 'Missionary')
Career.... | Ruby |
class AddStatsToCharacters < ActiveRecord::Migration
def self.up
add_column :characters, :weapon_skill, :integer, :null => false
add_column :characters, :ballistic_skill, :integer, :null => false
add_column :characters, :strength, :integer, :null => false
add_column :characters, :toughness, :integer, ... | Ruby |
class AddHomeWorldToCharacters < ActiveRecord::Migration
def self.up
add_column :characters, :home_world_id, :integer
end
def self.down
remove_column :characters, :home_world_id
end
end
| Ruby |
class CreateLureOfTheVoids < ActiveRecord::Migration
def self.up
create_table :lure_of_the_voids do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :lure_of_the_voids
end
end
| Ruby |
class CreateTrialsAndTravails < ActiveRecord::Migration
def self.up
create_table :trials_and_travails do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :trials_and_travails
end
end
| Ruby |
class DeviseCreateUsers < ActiveRecord::Migration
def self.up
create_table(:users) do |t|
t.database_authenticatable :null => false
t.recoverable
t.rememberable
t.trackable
# t.confirmable
# t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
# t.tok... | Ruby |
class CreateBirthrights < ActiveRecord::Migration
def self.up
create_table :birthrights do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :birthrights
end
end
| Ruby |
class AddSessionsTable < ActiveRecord::Migration
def self.up
create_table :sessions do |t|
t.string :session_id, :null => false
t.text :data
t.timestamps
end
add_index :sessions, :session_id
add_index :sessions, :updated_at
end
def self.down
drop_table :sessions
end
end
| Ruby |
class DefaultHomeWorlds < ActiveRecord::Migration
def self.up
HomeWorld.delete_all
HomeWorld.create(:name => 'Death World')
HomeWorld.create(:name => 'Void Born')
HomeWorld.create(:name => 'Forge World')
HomeWorld.create(:name => 'Hive World')
HomeWorld.create(:name => 'Imperial World')
... | Ruby |
class AddTrialsAndTravailsToCharacters < ActiveRecord::Migration
def self.up
add_column :characters, :trials_and_travails_id, :integer
end
def self.down
remove_column :characters, :trials_and_travails_id
end
end
| Ruby |
class CreateHomeWorlds < ActiveRecord::Migration
def self.up
create_table :home_worlds do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :home_worlds
end
end
| Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.