code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
# Install hook code here
puts 'Add the following inside the Rails::Initializer block in config/environment.rb:'
puts "\tconfig.active_record.schema_format = :sql" | Ruby |
# FulltextRow
#
# 2008-03-07
# Patched by Artūras Šlajus <x11@arturaz.net> for will_paginate support
class FulltextRow < ActiveRecord::Base
# If FULLTEXT_ROW_TABLE is set, use it as the table name
begin
set_table_name FULLTEXT_ROW_TABLE if Object.const_get('FULLTEXT_ROW_TABLE')
rescue
end
belongs_to :ful... | Ruby |
# ActsAsFulltextable
#
# 2008-03-07
# Patched by Artūras Šlajus <x11@arturaz.net> for will_paginate support
require "fulltext_row"
module ActsAsFulltextable
module ClassMethods
# Makes a model searchable.
# Takes a list of fields to use to create the index. It also take an option (:check_for_changes,
# w... | Ruby |
# Require any additional compass plugins here.
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "theme/css"
sass_dir = "theme/scss"
images_dir = "images"
javascripts_dir = "js"
# You can select your preferred output style here (can be overridden via the command line):
output_style = :co... | 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 error repor... | 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'
# Specifies gem version of Rails to use when vendor/rails is not present
#RAILS_GEM_VERSION... | 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|
map.connect 'wookiewiki/:action/:id', :controller => "wookie_wiki"
map.home '', :controller => "wiki", :action => "view"
map.login 'login', :controller => "account", :action => "login"
map.connect 'xml/:action/feed.xml', :controller => "xml"
map.edit 'edit', :... | Ruby |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
end
| Ruby |
module WikiHelper
end
| Ruby |
module AccountHelper
end
| Ruby |
module WookieWikiHelper
end
| Ruby |
module XmlHelper
end
| Ruby |
class Tiddler < ActiveRecord::Base
acts_as_versioned :limit => 10, :if => Proc.new { |t| !t.recently_revised? }, :if_changed => [ :body ]
validates_presence_of :title
def recently_revised?;
return false if new_record? or versions.length==0
versions.last.updated_on + 15.minutes > Time.now
end
# d... | Ruby |
class User
@@passwd = ''
cattr_accessor :passwd
end
| Ruby |
class Upload < Tiddler
DIRECTORY = 'public/uploaded'
after_create :process
after_destroy :cleanup
def file_data=(file_data)
@file_data = file_data
write_attribute 'extension',
file_data.original_filename.split('.').last.downcase
end
def url
path.sub(/^public/,'')
end
... | Ruby |
class XmlController < ApplicationController
def updated
@headers["Content-Type"] = "text/xml; charset=utf-8"
@tiddlers=Tiddler.find(:all, :order => "updated_on DESC", :conditions => ["private=?",false], :limit => 15)
title=Tiddler.find_by_title( "SiteTitle")
@feed_title=title.body if title
subtitle=... | Ruby |
class WikiController < ApplicationController
before_filter :login_required, :only => [ :destroy, :edit ]
def view
@tiddlers=Tiddler.find(:all, :conditions => ['private=?',false])
render :action => "show", :layout => false
end
def edit
@tiddlers=Tiddler.find(:all)
render :action => "show", :layout => ... | Ruby |
class WookieWikiController < ApplicationController
def upload
@tiddler = Upload.new( params[:tiddler])
if @tiddler.title == "New File Upload"
responds_to_parent do
render :update do |page|
page << "alert('Please enter a title.');"
end
end
return
end
@tidd... | Ruby |
class AccountController < ApplicationController
def login
return unless @request.post?
if params[:user_password]==User.passwd
@session[:user]=true
return redirect_to(:edit_url)
end
flash.now['bad'] = "Login unsuccessful, try again."
end
def logout
@session[:user] = nil
redi... | Ruby |
require_dependency "login_system"
class ApplicationController < ActionController::Base
include LoginSystem
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/local/bin/ruby
if ARGV.empty?
puts "Usage: benchmarker times 'Person.expensive_way' 'Person.another_expensive_way' ..."
exit
end
require File.dirname(__FILE__) + '/../config/environment'
require 'benchmark'
include Benchmark
# Don't include compilation in the benchmark
ARGV[1..-1].each { |expression| eva... | 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/local/bin/ruby
if ARGV.empty?
puts "Usage: benchmarker times 'Person.expensive_way' 'Person.another_expensive_way' ..."
exit
end
require File.dirname(__FILE__) + '/../config/environment'
require 'benchmark'
include Benchmark
# Don't include compilation in the benchmark
ARGV[1..-1].each { |expression| eva... | 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/local/bin/ruby
if ARGV.empty?
$stderr.puts "Usage: profiler 'Person.expensive_method(10)' [times]"
exit(1)
end
# Keep the expensive require out of the profile.
$stderr.puts 'Loading Rails...'
require File.dirname(__FILE__) + '/../config/environment'
# Define a method to profile.
if ARGV[1] and ARGV[1].to_i... | 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/boot'
require 'commands/process/reaper'
| 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/spinner'
| 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/spinner'
| 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/destroy' | Ruby |
#!/usr/local/bin/ruby
if ARGV.empty?
$stderr.puts "Usage: profiler 'Person.expensive_method(10)' [times]"
exit(1)
end
# Keep the expensive require out of the profile.
$stderr.puts 'Loading Rails...'
require File.dirname(__FILE__) + '/../config/environment'
# Define a method to profile.
if ARGV[1] and ARGV[1].to_i... | 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/server' | 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/plugin' | Ruby |
class CreateUploads < ActiveRecord::Migration
def self.up
add_column :tiddlers, :type, :string
end
def self.down
remove_column :tiddlers, :type
end
end
| Ruby |
class AddColToTiddlerVersion < ActiveRecord::Migration
def self.up
add_column :tiddler_versions, :type, :string
add_column :tiddler_versions, :extension, :string
end
def self.down
remove_column :tiddler_versions, :extension
remove_column :tiddler_versions, :type
end
end
| Ruby |
class AddExtensionColumnToTiddlers < ActiveRecord::Migration
def self.up
add_column :tiddlers, :extension, :string
end
def self.down
remove_column :tiddlers, :extension
end
end
| Ruby |
# =============================================================================
# A set of rake tasks for invoking the Capistrano automation utility.
# =============================================================================
# Invoke the given actions via Capistrano
def cap(*parameters)
begin
require 'rubyg... | Ruby |
require_dependency "user"
module LoginSystem
protected
def self.included(base)
base.send :helper_method, :logged_in?
end
def logged_in?
session[:user]
end
def login_required
return true if logged_in?
access_denied
return false
end
def access_denied
redirect_to :con... | 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 impai... | Ruby |
#!/opt/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 impai... | Ruby |
#!/opt/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 |
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
class Test::Unit::TestCase
# Transactional fixtures accelerate your tests by wrapping each test method
# in a transaction that's rolled back on completion. This ensures that the
# test datab... | Ruby |
require 'sinatra/activerecord/rake'
require './main' | 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 |
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 |
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 |
# 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 CreateWords < ActiveRecord::Migration
def change
create_table :words do |t|
t.column :user_id, :integer, :null => false
t.column :original_word, :string, :null => false
t.timestamps
end
end
end
| Ruby |
class CreateTranslations < ActiveRecord::Migration
def change
create_table :translations do |t|
t.column :is_valid, :boolean, :default => true, :null => false
t.column :trans, :string, :null => false
t.column :word_id, :integer, :default => 0, :null => false
t.timestamps
end
end
end
| Ruby |
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.column :user_name, :string, :null => false
t.column :password, :string, :null => false
t.timestamps
end
end
end
| 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 |
#!/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__)
RubySite::Application.load_tasks
| Ruby |
source 'https://rubygems.org'
gem 'rails', '3.2.0.rc2'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
gem 'json'
gem "dynamic_form"
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~>... | Ruby |
module CreateWordHelper
SPLITTER = ','
EMPTY = ""
SPACE = " "
class CreationErrors < StandardError
end
end | Ruby |
module ApplicationHelper
end
| Ruby |
module MainPageHelper
end
| Ruby |
module LoginHelper
end
| Ruby |
module ApiHelper
end
| Ruby |
module RegisterHelper
end
| Ruby |
class EditWordStorage
def initialize(original_word, translations, invalid_translations)
@original_word = original_word.to_s.strip
@translations = translations.to_s.strip
@invalid_translations = invalid_translations.to_s.strip
end
#method should return new storage
def self.from_word(word)
... | Ruby |
class User < ActiveRecord::Base
validates_uniqueness_of :user_name, :message => (I18n.t :currently_exists)
validates_presence_of :user_name, :message => (I18n.t :can_not_be_empty)
validates_presence_of :password, :message => (I18n.t :can_not_be_empty)
validates_confirmation_of :password, :message => (I18n.t :c... | Ruby |
class Translation < ActiveRecord::Base
validates_presence_of :trans
validates_presence_of :word_id
end
| Ruby |
class Word < ActiveRecord::Base
validates_presence_of :user_id
validates_presence_of :original_word
has_many :translations, :class_name => "Translation", :dependent => :destroy, :autosave => true, :foreign_key => :word_id
end
| Ruby |
require "builder"
class ApiController < ApplicationController
def get_dict
un = request[:un]
pwd = request[:pwd]
act = request[:act]
if un == nil || pwd == nil || act == nil
redirect_to :controller => "error", :action => "error"
end
user = User.find_by_user_name(un)
if !user || !... | Ruby |
class ApplicationController < ActionController::Base
protect_from_forgery
end
| Ruby |
class RegisterController < ApplicationController
def register
if request.post? and params[:user]
@user = User.new(params[:user])
if @user.save
flash[:notice] = I18n.t :thank_for_registration
redirect_to :controller => 'login', :action => :login
end
else
@user = User.n... | Ruby |
class LoginController < ApplicationController
def login
if request.post? and params[:user]
@user = User.new(params[:user])
user = User.find_by_user_name(@user.user_name)
if user and user.password_matches?(@user.password)
session[:user_id] = user.id
redirect_to :controller => :... | Ruby |
class MainPageController < ApplicationController
def main
@user_id = session[:user_id]
if (@user_id == nil)
redirect_to :controller => 'login', :action => :login
end
if request[:word] != nil && request[:should] != nil
if request[:should] == "remove"
remove(request[:word])
e... | Ruby |
class CreateWordController < ApplicationController
def create
user_id = session[:user_id]
if user_id == nil
redirect_to :controller => "login", :action => "login"
end
@storage = EditWordStorage.new("", "", "")
if request.post?
@storage = EditWordStorage.new(request.params["original... | 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 |
# 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.
# 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.
RubySite::Application.config.session_store :cookie_store, :key => '_rubySite_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 "ra... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.