code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
class WebsiteController < ApplicationController
def index
end
end | Ruby |
class ForumsController < ApplicationController
before_filter :set_current_menu_and_title
def index
@forums = Forum.find(:all, :order => "sequence asc")
@forums.each do |f|
p = Post.find_by_forum_id(f.id, :order => "created_at desc")
f.last_post = p
end
@rss_forums = Post.find(:all,... | Ruby |
class ResourcesController < ApplicationController
before_filter :login_required, :only => [:new, :edit, :create, :update, :destroy]
before_filter :set_current_menu_and_title
def index
@resources = Resource.paginate(:per_page => 10, :page => params[:page], :order => 'created_at desc')
@rss_resources = ... | Ruby |
class BlogCommentsController < ApplicationController
# GET /blog_comments
# GET /blog_comments.xml
def index
@blog_comments = BlogComment.find(:all)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @blog_comments }
end
end
# GET /blog_comments/1
# GE... | Ruby |
class PostsController < ApplicationController
before_filter :login_required, :only => [:new, :edit, :create, :update, :destroy]
before_filter :set_current_menu_and_title
def index
@posts = Post.find(:all)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @... | Ruby |
class AdminController < ApplicationController
before_filter :admin_required, :only => [:index, :send_email]
before_filter :set_current_menu_and_title
def index
@current_menu = :nil
end
def send_email
all_user = params[:all_user]
email_recipient = params[:email_recipient]
e... | Ruby |
class CommentsController < ApplicationController
before_filter :login_required, :only => [:new, :edit, :create, :update, :destroy]
before_filter :set_current_menu_and_title
def index
@comments = Comment.find(:all)
respond_to do |format|
format.html # index.html.erb
format.xml { render :x... | 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
render :layout => false
end
def create
self.current... | Ruby |
class BlogsController < ApplicationController
before_filter :login_required, :only => [:new, :edit, :create, :update, :destroy]
before_filter :set_current_menu_and_title
def index
@blogs = Blog.paginate(:per_page => 10, :page => params[:page], :order => 'created_at desc')
@rss_blogs = Blog.find(:all, ... | Ruby |
class IndexController < ApplicationController
def index
subdomain = request.subdomains[0]
if subdomain && subdomain != "www"
@user = User.find_by_login(subdomain)
if @user
@blogs = Blog.find(:all, :limit => 10, :conditions => ['user_id = ?', @user.id], :order => 'created_at desc'... | 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
include AuthenticatedSystem
before_filter :set_charset
before_filter :configure_charsets
def set_... | Ruby |
class TagsController < ApplicationController
before_filter :set_current_menu_and_title
def index
@tags = Tag.counts
end
def show
if request.request_uri.include?('.')
redirect_to request.request_uri[0, request.request_uri.index('.')]
return
end
@tag = Tag.find_by_name(CGI.unesc... | Ruby |
class UsersController < ApplicationController
# Be sure to include AuthenticationSystem in Application Controller instead
include AuthenticatedSystem
# render new.rhtml
def new
render :layout => false
end
def create
cookies.delete :auth_token
# protects against session fixation attacks, wre... | 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.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/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/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/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/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/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/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/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/inspector'
| 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/spawner'
| 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/destroy'
| 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 CreateBlogComments < ActiveRecord::Migration
def self.up
create_table :blog_comments do |t|
t.integer :user_id
t.string :site
t.string :name
t.text :content
t.integer :blog_id
t.timestamps
end
end
def self.down
drop_table :blog_comments
end
end
| Ruby |
class AddSequenceToForums < ActiveRecord::Migration
def self.up
add_column :forums, :sequence, :integer
remove_column :forum_category_id
end
def self.down
remove_column :forums, :sequence
end
end
| Ruby |
class CreateForums < ActiveRecord::Migration
def self.up
create_table :forums do |t|
t.string :title
t.string :description
t.integer :forum_category_id
t.integer :posts_count, :default => 0
t.integer :comments_count, :default => 0
t.timestamps
end
end
def self.down
... | Ruby |
class CreateTutorials < ActiveRecord::Migration
def self.up
create_table :tutorials do |t|
t.string :title
t.text :content
t.integer :user_id
t.timestamps
end
end
def self.down
drop_table :tutorials
end
end
| Ruby |
class CreateUsers < ActiveRecord::Migration
def self.up
create_table "users", :force => true do |t|
t.column :login, :string
t.column :email, :string
t.column :crypted_password, :string, :limit => 40
t.column :salt, :str... | Ruby |
class CreateResources < ActiveRecord::Migration
def self.up
create_table :resources do |t|
t.string :title
t.text :description
t.string :url
t.integer :user_id
t.timestamps
end
end
def self.down
drop_table :resources
end
end
| Ruby |
class AddViewsCountToPosts < ActiveRecord::Migration
def self.up
add_column :posts, :views_count, :integer, :default => 0
end
def self.down
remove_column :posts, :views_count
end
end
| Ruby |
class CreateEmailQueues < ActiveRecord::Migration
def self.up
create_table :email_queues do |t|
t.string :subject
t.text :content
t.string :recipient
t.timestamps
end
end
def self.down
drop_table :email_queues
end
end
| Ruby |
class CreateComments < ActiveRecord::Migration
def self.up
create_table :comments do |t|
t.text :content
t.integer :forum_id
t.string :post_id
t.integer :user_id
t.timestamps
end
end
def self.down
drop_table :comments
end
end
| Ruby |
class ActsAsTaggableMigration < ActiveRecord::Migration
def self.up
create_table :tags do |t|
t.column :name, :string
end
create_table :taggings do |t|
t.column :tag_id, :integer
t.column :taggable_id, :integer
# You should make sure that the column created is... | Ruby |
class CreateBlogs < ActiveRecord::Migration
def self.up
create_table :blogs do |t|
t.string :title
t.text :content
t.integer :user_id
t.integer :blog_comments_count, :default => 0
t.timestamps
end
end
def self.down
drop_table :blogs
end
end
| Ruby |
class AddIsAdminToUsers < ActiveRecord::Migration
def self.up
add_column :users, :is_admin, :boolean, :default => 0
end
def self.down
remove_column :users, :is_admin
end
end
| Ruby |
class CreateProfiles < ActiveRecord::Migration
def self.up
create_table :profiles do |t|
t.string :avatar_path
t.integer :user_id
t.timestamps
end
end
def self.down
drop_table :profiles
end
end
| Ruby |
class AddContentTypeToEmailqueues < ActiveRecord::Migration
def self.up
add_column :email_queues, :content_type, :string, :default => "text/plain"
end
def self.down
remove_column :email_queues, :is_admin
end
end
| Ruby |
class CreatePosts < ActiveRecord::Migration
def self.up
create_table :posts do |t|
t.string :title
t.text :content
t.integer :forum_id
t.integer :user_id
t.integer :comments_count, :default => 0
t.timestamps
end
end
def self.down
drop_table :posts
end
end
| Ruby |
module AuthenticatedSystem
protected
# Returns true or false if the user is logged in.
# Preloads @current_user with the user model if they're logged in.
def logged_in?
!!current_user
end
# Accesses the current user from the session.
# Future calls avoid the database because nil is not... | Ruby |
#!D:/ruby/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 impaired... | Ruby |
#!D:/ruby/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 impaired... | Ruby |
#!/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 FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log
# an... | Ruby |
#!D:/ruby/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 impaired... | Ruby |
#!D:/ruby/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 impaired... | Ruby |
#!/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 FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log
# an... | Ruby |
#!/usr/bin/env ruby
# Tool for creating a new unit test case.
require 'erb'
def main
if ARGV.size != 1
usage()
exit 1
end
class_name = ARGV[0]
if class_name !~ /^[a-z0-9]+$/i
print "'#{class_name}' doesn't look like a valid class name.\n"
exit 1
end
header = find_header(class_name)
if header.nil?
p... | Ruby |
#!/usr/bin/env ruby
# Tool for creating a new unit test case.
require 'erb'
def main
if ARGV.size != 1
usage()
exit 1
end
class_name = ARGV[0]
if class_name !~ /^[a-z0-9]+$/i
print "'#{class_name}' doesn't look like a valid class name.\n"
exit 1
end
header = find_header(class_name)
if header.nil?
p... | Ruby |
#!/usr/bin/env ruby
# Tool for creating a new unit test case.
require 'erb'
def main
if ARGV.size != 1
usage()
exit 1
end
class_name = ARGV[0]
if class_name !~ /^[a-z0-9]+$/i
print "'#{class_name}' doesn't look like a valid class name.\n"
exit 1
end
header = find_header(class_name)
if header.nil?
p... | Ruby |
#!/usr/bin/env ruby
# Tool for creating a new unit test case.
require 'erb'
def main
if ARGV.size != 1
usage()
exit 1
end
class_name = ARGV[0]
if class_name !~ /^[a-z0-9]+$/i
print "'#{class_name}' doesn't look like a valid class name.\n"
exit 1
end
header = find_header(class_name)
if header.nil?
p... | Ruby |
#!/usr/bin/env ruby
# Tool for creating a new unit test case.
require 'erb'
def main
if ARGV.size != 1
usage()
exit 1
end
class_name = ARGV[0]
if class_name !~ /^[a-z0-9]+$/i
print "'#{class_name}' doesn't look like a valid class name.\n"
exit 1
end
header = find_header(class_name)
if header.nil?
p... | Ruby |
#!/usr/bin/env ruby
# Tool for creating a new unit test case.
require 'erb'
def main
if ARGV.size != 1
usage()
exit 1
end
class_name = ARGV[0]
if class_name !~ /^[a-z0-9]+$/i
print "'#{class_name}' doesn't look like a valid class name.\n"
exit 1
end
header = find_header(class_name)
if header.nil?
p... | 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 |
# 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 |
# Is sheet 01 (after the TOC) a left sheet or a right sheet?
sheet1: right
# "left" and "right" specify which page of a two-page spread a file
# must start on. "left" means that a file must start on the first of
# the two pages. "right" means it must start on the second of the two
# pages. The file may start in eit... | Ruby |
#
# This file is only needed for Compass/Sass integration. If you are not using
# Compass, you may safely ignore or delete this file.
#
# If you'd like to learn more about Sass and Compass, see the sass/_README.txt
# file for more information.
#
# This config file is borrowed from Zen, so thanks JohnAlbin for your hard... | Ruby |
#
# This file is only needed for Compass/Sass integration. If you are not using
# Compass, you may safely ignore or delete this file.
#
# If you'd like to learn more about Sass and Compass, see the sass/_README.txt
# file for more information.
#
# This config file is borrowed from Zen, so thanks JohnAlbin for your hard... | Ruby |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
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
protect_from_forgery # See ActionController::RequestForgeryPr... | Ruby |
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
class ActiveSupport::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 da... | 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' }])
# Major.create(:name... | Ruby |
#!/usr/bin/ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/plugin'
| Ruby |
#!/usr/bin/ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/runner'
| Ruby |
#!/usr/bin/ruby
require File.expand_path('../../config/boot', __FILE__)
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'commands/about'
| Ruby |
#!/usr/bin/ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/dbconsole'
| Ruby |
#!/usr/bin/ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/generate'
| Ruby |
#!/usr/bin/ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/server'
| Ruby |
#!/usr/bin/ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/plugin'
| Ruby |
#!/usr/bin/ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/destroy'
| Ruby |
#!/usr/bin/ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/runner'
| Ruby |
#!/usr/bin/ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/console'
| Ruby |
#!/usr/bin/ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/console'
| Ruby |
#!/usr/bin/ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/server'
| Ruby |
#!/usr/bin/ruby
require File.expand_path('../../config/boot', __FILE__)
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'commands/about'
| Ruby |
#!/usr/bin/ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/destroy'
| Ruby |
#!/usr/bin/ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/generate'
| Ruby |
#!/usr/bin/ruby
require File.expand_path('../../../config/boot', __FILE__)
require 'commands/performance/benchmarker'
| Ruby |
#!/usr/bin/ruby
require File.expand_path('../../../config/boot', __FILE__)
require 'commands/performance/profiler'
| Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.