code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
class AddSomeIndices < ActiveRecord::Migration
def self.up
add_index :people, :admin
add_index :people, :deactivated
add_index :blogs, :person_id
add_index :activities, :person_id
end
def self.down
remove_index :activities, :person_id
remove_index :blogs, :person_id
remove_index :peop... | Ruby |
class CreatePreferences < ActiveRecord::Migration
def self.up
# drop_table :preferences rescue nil
create_table :preferences do |t|
t.string :domain, :null => false, :default => ""
t.string :smtp_server, :null => false, :default => ""
t.boolean :email_notifications, :null => false, :default ... | Ruby |
class CreateEvents < ActiveRecord::Migration
def self.up
create_table :events do |t|
t.integer :person_id
t.timestamps
end
end
def self.down
drop_table :events
end
end
| Ruby |
class FixUpPageViews < ActiveRecord::Migration
def self.up
remove_column :page_views, :user_id
add_column :page_views, :person_id, :integer
add_index :page_views, [:person_id, :created_at]
end
def self.down
add_column :page_views, :user_id, :integer
remove_column :page_views, :perso... | Ruby |
class CreateCategoryts < ActiveRecord::Migration
def self.up
create_table :categoryts do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :categoryts
end
end
| Ruby |
class CreateComments < ActiveRecord::Migration
def self.up
create_table :comments do |t|
t.integer :commenter_id
t.integer :commentable_id
t.string :commentable_type, :default => "", :null => false
t.text :body
t.timestamps
end
add_index :comments, :commenter_id
add_... | Ruby |
class CreateConversations < ActiveRecord::Migration
def self.up
create_table :conversations do |t|
# We only need the id, but the migration chokes if we don't pass a block.
end
add_column :communications, :conversation_id, :integer
add_index :communications, :conversation_id
system("rake db:... | Ruby |
class RemoveSessionColumn < ActiveRecord::Migration
def self.up
remove_column :page_views, :session
end
def self.down
add_column :page_views, :session, :string, :limit => 32
end
end
| Ruby |
class CreatePageView < ActiveRecord::Migration
def self.up
create_table :page_views do |t|
t.integer :user_id
t.string :request_url, :limit => 200
t.string :session, :limit => 32
t.string :ip_address, :limit => 16
t.string :referer, :limit => 200
t.string :user_agent, :limit =>... | Ruby |
class AddViewCountsAndMediaUrlToPosts < ActiveRecord::Migration
def self.up
add_column :posts,:view_count,:integer,:null => false, :default => 0
add_column :posts,:media_url,:string
end
def self.down
remove_column :posts,:view_count
remove_column :posts,:media_url
end
end
| Ruby |
class CreateCategories < ActiveRecord::Migration
def self.up
create_table :categories do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :categories
end
end
| Ruby |
class CreateArticleComments < ActiveRecord::Migration
def self.up
create_table :article_comments do |t|
t.integer :article_id,:null=>false,:default =>0
t.text :body
t.integer :person_id,:null=>false,:default =>0
t.timestamps
end
end
def self.down
drop_table :article_comments
... | Ruby |
class CreateArticles < ActiveRecord::Migration
def self.up
create_table :articles do |t|
t.integer :categoryt_id,:null=>false,:default=>0
t.integer :category_id,:null=>false,:default=>0
t.integer :person_id,:null=>false,:default=>0
t.string :title
t.integer :view_count,:null=>false,:... | Ruby |
class CreateEmailVerifications < ActiveRecord::Migration
def self.up
create_table :email_verifications do |t|
t.integer :person_id
t.string :code
t.timestamps
end
add_index :email_verifications, :code
end
def self.down
drop_table :email_verifications
end
end
| Ruby |
class AddAboutToPreferences < ActiveRecord::Migration
def self.up
add_column :preferences, :about, :text
end
def self.down
remove_column :preferences, :about
end
end
| Ruby |
class AddAnalyticsPreference < ActiveRecord::Migration
def self.up
add_column :preferences, :analytics, :text
end
def self.down
remove_column :preferences, :analytics
end
end
| Ruby |
class AddDemoBoolean < ActiveRecord::Migration
def self.up
add_column :preferences, :demo, :boolean, :default => false
end
def self.down
remove_column :preferences, :demo
end
end
| Ruby |
class FixMessageParentId < ActiveRecord::Migration
def self.up
# This converts the communications parent_id from a string to an integer.
# Amazingly, it works as a string, which is why it took a while to
# notice the problem. Even more amazingly, this conversion works
# even for an existing database;... | Ruby |
class CreateTags < ActiveRecord::Migration
def self.up
create_table :tags do |t|
t.string :name
t.integer :creater,:null=>false,:default=>0
t.timestamps
end
end
def self.down
drop_table :tags
end
end
| Ruby |
class RenameEventsToActivities < ActiveRecord::Migration
def self.up
remove_index :events, :item_id
remove_index :events, :item_type
remove_index :feeds, [:person_id, :event_id]
rename_table :events, :activities
rename_column :feeds, :event_id, :activity_id
add_index :activities, ... | Ruby |
class CreatePhotos < ActiveRecord::Migration
def self.up
create_table :photos do |t|
t.integer :person_id
t.integer :parent_id
t.string :content_type
t.string :filename
t.string :thumbnail
t.integer :size
t.integer :width
t.integer :height
t.boolean :primar... | Ruby |
class CreatePeople < ActiveRecord::Migration
def self.up
create_table "people", :force => true do |t|
t.string :email, :name, :remember_token, :crypted_password
t.text :description
t.datetime :remember_token_expires_at,
:last_contacted_at,
:last_logged_in_... | Ruby |
class CreateCommunications < ActiveRecord::Migration
def self.up
create_table :communications do |t|
t.string :subject
t.text :content
t.string :parent_id
t.integer :sender_id
t.integer :recipient_id
t.datetime :sender_deleted_at
t.datetime :sender_read_at
... | Ruby |
class CreateEventsAndFeed < ActiveRecord::Migration
def self.up
create_table :events do |t|
t.boolean :public
t.integer :item_id
t.integer :person_id
t.string :item_type
t.timestamps
end
add_index :events, :item_id
add_index :events, :item_type
create_table :fee... | Ruby |
class CreateConnections < ActiveRecord::Migration
def self.up
create_table :connections do |t|
t.integer :person_id
t.integer :contact_id
t.integer :status
t.timestamp :accepted_at
t.timestamps
end
add_index :connections, [:person_id, :contact_id]
end
def self.down
... | Ruby |
class AddCategorytCategoryTagIdToBlog < ActiveRecord::Migration
def self.up
add_column :posts,:category_id,:integer,:null => false, :default => 0
add_column :posts,:categoryt_id,:integer,:null => false, :default => 0
end
def self.down
remove_column :posts, :category_id
remove_column :posts, :cate... | Ruby |
class AddEmailVerified < ActiveRecord::Migration
class Person < ActiveRecord::Base
end
def self.up
add_column :people, :email_verified, :boolean, :default => nil
if Preference.find(:first).email_verifications?
# This is to modify the database for the splitting between
# 'deactivated'... | Ruby |
#!/usr/local/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 impai... | Ruby |
#!/usr/local/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.lo... | Ruby |
#!/usr/local/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 impai... | Ruby |
#!/usr/local/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 ... | Ruby |
#!/usr/local/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.lo... | Ruby |
#!/usr/local/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 ... | 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/boot'
require 'commands/runner'
| Ruby |
#!/usr/bin/env ruby
# Create some files and directories so they won't be created as root.
# This doesn't do the actual installation, since that needs to be done as root.
system("rake gems:install")
# Install the gem dependencies (if any).
system("sudo rake gems:install")
# Run the main install task.
system("rake insta... | 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
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../vendor/plugins/rspec/lib' # For rspec installed as plugin
require 'rubygems'
require 'drb/drb'
require 'rbconfig'
require 'spec'
require 'optparse'
# This is based on Florian Weber's TDDMate
module Spec
module Runner
class RailsSpecServer
... | 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
# Create some files and directories so they won't be created as root.
# This doesn't do the actual installation, since that needs to be done as root.
system("rake gems:install")
# Install the gem dependencies (if any).
system("sudo rake gems:install")
# Run the main install task.
system("rake insta... | Ruby |
#!/usr/bin/env ruby
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../vendor/plugins/rspec/lib"))
require 'spec'
exit ::Spec::Runner::CommandLine.run(::Spec::Runner::OptionParser.parse(ARGV, STDERR, STDOUT))
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/about'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/server'
| Ruby |
#!/usr/bin/env ruby
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../vendor/plugins/rspec/lib"))
require 'spec'
exit ::Spec::Runner::CommandLine.run(::Spec::Runner::OptionParser.parse(ARGV, STDERR, STDOUT))
| 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
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../vendor/plugins/rspec/lib' # For rspec installed as plugin
require 'rubygems'
require 'drb/drb'
require 'rbconfig'
require 'spec'
require 'optparse'
# This is based on Florian Weber's TDDMate
module Spec
module Runner
class RailsSpecServer
... | 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 |
module CustomModelMatchers
# Verify that a model instance has a maximum length on the given attribute.
class MaximumLength
def initialize(attribute, maxlength)
@attribute = attribute
@maxlength = maxlength
end
def matches?(model)
@model = model
just_right = model
to... | Ruby |
# This file is copied to ~/spec when you run 'ruby script/generate rspec'
# from the project root directory.
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'spec'
require 'spec/rails'
include AuthenticatedTestHelper
Spec::Runner.configure do |config|
# A... | Ruby |
unless ActiveRecord::Base.respond_to? :paginate
require 'will_paginate'
WillPaginate.enable
end
| Ruby |
# This is currently unused, but a nice example of how to make a cache sweeper.
class ActivitySweeper < ActionController::Caching::Sweeper
observe Activity
def after_create(activity)
clear_cache
end
def after_destroy(activity)
clear_cache
end
private
def clear_cache
logger.info ... | Ruby |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
## Menu helpers
def menu
home = menu_element("Home", home_path)
people = menu_element("People", people_path)
if Forum.count == 1
forum = menu_element("Forum", forum_path(For... | Ruby |
module PreferencesHelper
# Return the global preferences.
# The separate line for test mode lets the tests change the global prefs
# on a test-by-test basis. Without that line, changes to the prefs
# don't show up because of the ||=. Usually, this is a feature (avoiding
# the redundant database hits is the... | Ruby |
module PeopleHelper
def message_links(people)
people.map { |p| email_link(p)}
end
# Return a person's image link.
# The default is to display the person's icon linked to the profile.
def image_link(person, options = {})
link = options[:link] || person
image = options[:image] || :icon
image_o... | Ruby |
module SearchesHelper
# Return the model to be searched based on params.
def search_model
return "Person" if params[:controller] =~ /home/
return "ForumPost" if params[:controller] =~ /forums/
params[:model] || params[:controller].classify
end
def search_type
if params[:controller] == "... | Ruby |
module ConnectionsHelper
end
| Ruby |
module ArticleCommentsHelper
end
| Ruby |
module SessionsHelper
end | Ruby |
module TopicsHelper
end
| Ruby |
module FriendsHelper
end
| Ruby |
module EmailVerificationsHelper
end
| Ruby |
module PostsHelper
end
| Ruby |
module CommunicationsHelper
def contact_links(requested_contacts)
requested_contacts.map do |contact|
conn = Connection.conn(current_person, contact)
edit_connection_path(conn)
end
end
def message_anchor(message)
"message_#{message.id}"
end
end
| Ruby |
module MessagesHelper
def list_link_with_active(name, options = {}, html_options = {}, &block)
opts = {}
opts.merge!(:class => "active") if current_page?(options)
content_tag(:li, link_to(name, options, html_options, &block), opts)
end
end | Ruby |
module PhotosHelper
end
| Ruby |
module ForumsHelper
def forum_name(forum)
forum.name.nil? || forum.name.blank? ? "Forum ##{forum.id}" : forum.name
end
end
| Ruby |
module CategoriesHelper
end
| Ruby |
# Helpers added to this module are available in both controllers and views.
module SharedHelper
def current_person?(person)
logged_in? and person == current_person
end
# Return true if a person is connected to (or is) the current person
def connected_to?(person)
current_person?(person) or Connection... | Ruby |
module ActivitiesHelper
# Given an activity, return a message for the feed for the activity's class.
def feed_message(activity)
person = activity.person
case activity_type(activity)
when "BlogPost"
post = activity.item
blog = post.blog
view_blog = blog_link("View #{h person.name}'s bl... | Ruby |
module CategorytsHelper
end
| Ruby |
module ArticlesHelper
end
| Ruby |
module TagsHelper
end
| Ruby |
module HomeHelper
end
| Ruby |
module CommentsHelper
end
| Ruby |
module BlogsHelper
end
| Ruby |
class ArticleApi < ActionWebService::API::Base
api_method :ins_article,
:expects => [{:title=>:string},{:synopsis=>:string},{:body=>:string},{:user_published_by=>:string},{:media_url=>:string},{:email_addr=>:string},{:category_f=>:string},{:photou=>:string},{:uprofile=>:string},{:categoryt_f=>:string}... | Ruby |
# == Schema Information
# Schema version: 26
#
# Table name: posts
#
# id :integer(11) not null, primary key
# blog_id :integer(11)
# topic_id :integer(11)
# person_id :integer(11)
# title :string(255)
... | Ruby |
# == Schema Information
# Schema version: 26
#
# Table name: page_views
#
# id :integer(11) not null, primary key
# request_url :string(200)
# ip_address :string(16)
# referer :string(200)
# user_agent :string(200)
# created_at :datetime
# updated_at :datetime ... | Ruby |
# == Schema Information
# Schema version: 26
#
# Table name: preferences
#
# id :integer(11) not null, primary key
# domain :string(255) default(""), not null
# smtp_server :string(255) default(""), not null
# email_notifications :boolean(1) not null
# email_v... | Ruby |
# == Schema Information
# Schema version: 26
#
# Table name: photos
#
# id :integer(11) not null, primary key
# person_id :integer(11)
# parent_id :integer(11)
# content_type :string(255)
# filename :string(255)
# thumbnail :string(255)
# size :integer(... | Ruby |
# == Schema Information
# Schema version: 26
#
# Table name: email_verifications
#
# id :integer(11) not null, primary key
# person_id :integer(11)
# code :string(255)
# created_at :datetime
# updated_at :datetime
#
class EmailVerification < ActiveRecord::Base
belong... | Ruby |
# == Schema Information
# Schema version: 26
#
# Table name: people
#
# id :integer(11) not null, primary key
# email :string(255)
# name :string(255)
# remember_token :string(255)
# crypted_password :string... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.