code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
# 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 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.... | 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 |
ActionController::Routing::Routes.draw do |map|
map.resources :categories
map.connect "webcomics/search", :controller => "webcomics", :action => "search"
map.connect "webcomics/results", :controller => "webcomics", :action => "results"
map.resources :webcomics do |webcomic|
webcomic.resources :stri... | Ruby |
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
Dir['lib/recipes/*.rb'].each { |plugin| load(plugin) }
load 'config/deploy'
| Ruby |
module StripsHelper
end
| Ruby |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
end
| Ruby |
module WebcomicsHelper
end
| Ruby |
module UsersHelper
#
# Use this to wrap view elements that the user can't access.
# !! Note: this is an *interface*, not *security* feature !!
# You need to do all access control at the controller level.
#
# Example:
# <%= if_authorized?(:index, User) do link_to('List all users', users_path) end %> ... | Ruby |
module SessionsHelper
end | Ruby |
module CategoriesHelper
end
| Ruby |
module CommentsHelper
end
| Ruby |
class Category < ActiveRecord::Base
has_and_belongs_to_many :webcomics
def self.getCategoryList()
@rows = find(:all, :order => "name ASC");
#@rows.map {|item| item.name};
end
def <=>(cat)
return self.name <=> cat.name
end
end
| Ruby |
class Strip < ActiveRecord::Base
belongs_to :webcomic
has_many :comments
has_attachment :content_type => :image,
:storage => :file_system
validates_as_attachment
validates_presence_of :title, :filename
validates_associated :webcomic
def self.getMostRecentStrip(p_webcomic_id)
allSt... | Ruby |
require 'digest/sha1'
class User < ActiveRecord::Base
include Authentication
include Authentication::ByPassword
include Authentication::ByCookieToken
has_many :comments
has_many :webcomics
validates_presence_of :login
validates_length_of :login, :within => 3..40
validates_uniqueness_of... | Ruby |
class Comment < ActiveRecord::Base
belongs_to :user
belongs_to :strip
validates_presence_of :user, :strip, :contents
validates_associated :user, :strip
end
| Ruby |
class Webcomic < ActiveRecord::Base
belongs_to :creator, :class_name => :user
has_and_belongs_to_many :categories
has_many :strips, :dependent => :destroy
validates_length_of :categories, :minimum => 1, :message => "must have at least one category"
validates_presence_of :title
def find_most_recent_strip... | Ruby |
class CommentsController < ApplicationController
before_filter :login_required, :except => [:show, :index]
# only webcomic creator and comment user have permission
before_filter :check_user, :only => [:edit, :update, :destroy]
# GET /comments
# GET /comments.xml
def index
@webcomic = Webcomi... | 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
logout_keeping_session!
user ... | Ruby |
class WebcomicsController < ApplicationController
before_filter :login_required, :except => [:show, :index, :show_comments, :show_all_comments,
:show_new_comment, :show_previous_comment, :show_next_comment, :show_strip,
:show_next_... | Ruby |
class CategoriesController < ApplicationController
# GET /categories
# GET /categories.xml
def index
@categories = Category.find(:all)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @categories }
end
end
# GET /categories/1
# GET /categories/1.xml
... | Ruby |
class StripsController < ApplicationController
before_filter :login_required
before_filter :check_user, :only => [:edit, :update, :destroy, :index]
# GET /strips
# GET /strips.xml
def index
@strips = Strip.find(:all, :conditions => {:webcomic_id => params[:webcomic_id]}, :order => "strip_number 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
helper :all # include all helpers, all the time
# See ActionController::Reques... | Ruby |
class UsersController < ApplicationController
# Be sure to include AuthenticationSystem in Application Controller instead
include AuthenticatedSystem
# render new.rhtml
def new
@user = User.new
end
def create
logout_keeping_session!
@user = User.new(params[:user])
success = @user && @user... | 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'
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'commands/about' | 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
$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/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
ENV['RSPEC'] = 'true'
system 'autotest' | 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/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
ENV['RSPEC'] = 'true'
system 'autotest' | 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/plugin'
| 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 |
class Addcategories < ActiveRecord::Migration
def self.up
Category.create :name => "Action"
Category.create :name => "Adventure"
Category.create :name => "Anime"
Category.create :name => "Comedy"
Category.create :name => "Parody"
Category.create :name => "Fantasy"
Category.create :name => ... | Ruby |
class AddWebcomicUseridsToRatingsAndWebcomics < ActiveRecord::Migration
def self.up
add_column :webcomics, :creator_id, :integer
end
def self.down
end
end
| Ruby |
class AddAssociationsToComments < ActiveRecord::Migration
def self.up
add_column :comments, :user_id, :integer
add_column :comments, :strip_id, :integer
end
def self.down
remove_column :comments, :user_id
remove_column :comments, :strip_id
end
end
| Ruby |
class CreateStrips < ActiveRecord::Migration
def self.up
create_table :strips do |t|
t.string :title
t.datetime :uploaddate
t.timestamps
end
end
def self.down
drop_table :strips
end
end
| Ruby |
class CreateUsers < ActiveRecord::Migration
def self.up
create_table "users", :force => true do |t|
t.column :login, :string, :limit => 40
t.column :name, :string, :limit => 100, :default => '', :null => true
t.column :email, :string, ... | Ruby |
class CreateWebcomics < ActiveRecord::Migration
def self.up
create_table :webcomics do |t|
t.string :title
t.datetime :creationtime
t.datetime :lastupdated
t.timestamps
end
end
def self.down
drop_table :webcomics
end
end
| Ruby |
class AddStripNumber < ActiveRecord::Migration
def self.up
add_column :strips, :strip_number, :integer
end
def self.down
remove_column :strips, :strip_number
end
end
| Ruby |
class RemoveTimestampColumns < ActiveRecord::Migration
def self.up
remove_column :strips, :uploaddate
remove_column :webcomics, :creationtime
remove_column :comments, :commentdate
end
def self.down
add_column :strips, :uploaddate, :datetime
add_column :webcomics, :creationtime, :datetime
... | Ruby |
class SetNumberOfViewsDefault < ActiveRecord::Migration
def self.up
change_column :webcomics, :number_of_views, :integer, :default => 0
end
def self.down
end
end
| Ruby |
class CreateComments < ActiveRecord::Migration
def self.up
create_table :comments do |t|
t.text :contents
t.integer :commentrating
t.datetime :commentdate
t.timestamps
end
end
def self.down
drop_table :comments
end
end
| Ruby |
class MakeCategoryWebcomicTable < ActiveRecord::Migration
def self.up
create_table :categories_webcomics, { :id => false } do |t|
t.column :category_id, :integer
t.column :webcomic_id, :integer
end
end
def self.down
drop_table :categories_webcomics
end
end
| Ruby |
class CreateRatings < ActiveRecord::Migration
def self.up
create_table :ratings do |t|
t.integer :value
t.timestamps
end
end
def self.down
drop_table :ratings
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 AddWebcomicIdToCategories < ActiveRecord::Migration
def self.up
add_column :categories, :webcomic_id, :integer
add_column :strips, :webcomic_id, :integer
end
def self.down
remove_column :categories, :webcomic_id
remove_column :strips, :webcomic_id
end
end
| Ruby |
class RemoveRatingsAddNumberOfViews < ActiveRecord::Migration
def self.up
#drop_table :ratings
#remove_column :users, :rating_id
#remove_column :webcomics, :rating_id
add_column :webcomics, :number_of_views, :integer
end
def self.down
end
end
| Ruby |
class DefaultCommentRatingZero < ActiveRecord::Migration
def self.up
change_column :comments, :commentrating, :integer, :default => 0
end
def self.down
end
end
| Ruby |
class StripImages < ActiveRecord::Migration
def self.up
## attachment_fu stuff ##
add_column :strips, "filename", :string, :limit => 255
add_column :strips, "path", :string, :limit => 255
add_column :strips, "content_type", :string
add_column :strips, "size", :integer
... | 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'
Spec::Runner.configure do |config|
# If you're not using ActiveRecord ... | 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 |
raise "To avoid rake task loading problems: run 'rake clobber' in vendor/plugins/rspec" if File.directory?(File.join(File.dirname(__FILE__), *%w[.. .. vendor plugins rspec pkg]))
raise "To avoid rake task loading problems: run 'rake clobber' in vendor/plugins/rspec-rails" if File.directory?(File.join(File.dirname(__FIL... | Ruby |
module AuthenticatedTestHelper
# Sets the current user in the session from the user fixtures.
def login_as(user)
@request.session[:user_id] = user ? users(user).id : nil
end
def authorize_as(user)
@request.env["HTTP_AUTHORIZATION"] = user ? ActionController::HttpAuthentication::Basic.encode_credentials... | Ruby |
namespace :deploy do
namespace :mongrel do
set :mongrel_clean, false
set :mongrel_rails, 'mongrel_rails'
set :mongrel_conf, nil
def set_mongrel_conf
set :mongrel_conf, "/etc/mongrel.yml" unless mongrel_conf
end
desc "Setup mongrel cluster configuration"
task :configure, :ro... | 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 |
#!/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 |
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 |
dir = File.dirname(__FILE__)
Dir[File.expand_path("#{dir}/**/*.rb")].uniq.each do |file|
require file
end | Ruby |
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'spec/rails/story_adapter' | Ruby |
#
# Copyright 2008 Garth Williams
#
# This file is part of CommandPost.
#
# CommandPost is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later ve... | Ruby |
#
# Copyright 2008 Garth Williams
#
# This file is part of CommandPost.
#
# CommandPost is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later ve... | Ruby |
#
# Copyright 2008 Garth Williams
#
# This file is part of CommandPost.
#
# CommandPost is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later ve... | Ruby |
#
# Copyright 2008 Garth Williams
#
# This file is part of CommandPost.
#
# CommandPost is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later ve... | Ruby |
#
# Copyright 2008 Garth Williams
#
# This file is part of CommandPost.
#
# CommandPost is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later ve... | Ruby |
#
# Copyright 2008 Garth Williams
#
# This file is part of CommandPost.
#
# CommandPost is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later ve... | Ruby |
#
# Copyright 2008 Garth Williams
#
# This file is part of CommandPost.
#
# CommandPost is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later ve... | Ruby |
#
# Copyright 2008 Garth Williams
#
# This file is part of CommandPost.
#
# CommandPost is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any ... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.