code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
#!/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/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/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/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/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/generate' | Ruby |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
def home_url
url_for :controller => 'schools', :action => 'index'
end
def show_datetime(time)
time += 8.hour # set timezone to utc, so +0800 for bj timezone
"#{time.year}-#{time.month}-#{t... | Ruby |
module SchoolsHelper
def need_icon(entry, text)
(entry ? image_tag("tick.png") : image_tag("cross.png")) + text
end
def tags_selector_for(input_field, tags)
result = ""
tags.each do |e|
result << "<a href=\"javascript:swap('#{input_field}','#{e}')\">#{e}</a> "
end
return result
e... | Ruby |
module BroadcastsHelper
end
| Ruby |
module GeoHelper
def areas_crumble_path_with_link(area)
result = ""
area.ancestors.each do |p|
result += yield(p) + " > "
end
result += area.title
end
end
| Ruby |
module BizHelper
end
| Ruby |
class Tour < ActiveRecord::Base
belongs_to :school
has_many :participations, :dependent => :destroy
has_many :participators, :through => :participations, :source => :user do
def leader
find :first, :order => 'created_at asc'
end
end
#has_many :discussions, :class_name => 'TourComment', :dependen... | Ruby |
class School < ActiveRecord::Base
belongs_to :area
belongs_to :user
belongs_to :province, :class_name => "Area", :foreign_key => "province_id"
def editable_by?(user)
user && (user.id == user_id || user.admin)
end
end
| Ruby |
class Participation < ActiveRecord::Base
belongs_to :tour
belongs_to :user
end
| Ruby |
require 'digest/sha1'
require 'digest/md5'
class User < ActiveRecord::Base
has_many :schools, :dependent => :destroy
has_one :yupoo_profile, :dependent => :destroy
has_many :broadcasts, :dependent => :destroy
has_many :tours, :dependent => :destroy
#validates_format_of :avatar_url, :with => /^.*(.jpg|.JPG|.g... | Ruby |
class Area < ActiveRecord::Base
acts_as_nested_set
has_many :schools, :dependent => :destroy
def self.conditions_by_like(value, *columns)
columns = self.column_names if columns.size == 0
columns = columns[0] if columns[0].kind_of?(Array)
conditions = columns.map { |c|
c = c.name if c.kind_... | Ruby |
class Broadcast < ActiveRecord::Base
belongs_to :sender, :class_name => "User", :foreign_key => 'from'
end
| Ruby |
class BroadcastsController < ApplicationController
layout "general"
before_filter :login_required, :only => :create
verify :only => :create, :method => :post, :redirect_to => {:controller => 'biz', :action => 'news'}
def index
list
end
def create
bc = Broadcast.new(params[:broadcast])
bc.f... | Ruby |
class GeoController < ApplicationController
layout "general"
def index
@provinces = Area.roots
end
def show
@area = Area.find(params[:id])
@map = GMap.new("map_div")
@map.control_init(:large_map => true,:map_type => Variable.new("G_HYBRID_MAP"))
@map.center_zoom_init([@area.lat,@area.l... | Ruby |
class ToursController < ApplicationController
layout 'general'
# GET /tours/1
def show
@tour = Tour.find(params[:id], :include => :school)
#@discussions = @tour.discussions.find(:all, :order => 'created_at asc')
#@discussion = TourComment.new
respond_to do |format|
format.html
end
e... | Ruby |
class UsersController < ApplicationController
# Be sure to include AuthenticationSystem in Application Controller instead
#include AuthenticatedSystem
layout "general"
# render new.rhtml
def new
end
def create
@user = User.new(params[:user])
@user.save!
bc = Broadcast.create(:site => 2, ... | 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
# Pick a unique cookie name to distinguish our session data from others'
session :session_key => '_aixin1kg_s... | Ruby |
class SchoolsController < ApplicationController
layout "general"
before_filter :login_required, :except => [:index, :show]
=begin
def homepage
@broadcasts = Broadcast.find(:all, :limit => 15,
:conditions => "broadcasts.site=2",
:order => "broad... | Ruby |
class BizController < ApplicationController
layout 'general'
def index
render :layout => false
end
def news
@broadcasts = Broadcast.find(:all, :limit => 15,
:conditions => "broadcasts.site=2",
:order => "broadcasts.created_at desc",... | 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
layout "general"
# render new.rhtml
def new
end
def create
self.current_user = U... | Ruby |
ActionController::Routing::Routes.draw do |map|
map.home '', :controller => 'biz', :action => 'index'
map.connect '/contact', :controller => 'biz', :action => 'contact'
map.connect '/intro', :controller => 'biz', :action => 'intro'
map.connect '/join', :controller => 'biz', :action => 'join'
map.connect '/sto... | 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 =~ /(:?mswin|mingw)/
require 'pathname'
root_path = Pathname.new(root_path).cleanpath(true).to_s
end
... | 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 |
# 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 |
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 != :false
end
# Accesses the current user from the session. Set it to :false if login fails
# so th... | Ruby |
module AuthenticatedTestHelper
# Sets the current user in the session from the user fixtures.
def login_as(user)
@request.session[:user] = user ? users(user).id : nil
end
def authorize_as(user)
@request.env["HTTP_AUTHORIZATION"] = user ? "Basic #{Base64.encode64("#{users(user).login}:test")}" : nil
e... | Ruby |
require 'zurb-foundation'
# Require any additional compass plugins here.
# Set this to the root of your project when deployed:
http_path = "/css"
css_dir = "../assets/css"
sass_dir = "sass"
images_dir = "img"
javascripts_dir = "javascripts"
# You can select your preferred output style here (can be overridden via the... | 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):
# Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# i... | 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.
# Include Active Record class name as root for JSON serialized output.
ActiveRecord::Base.include_root_in_json = true
# Store the full class name (including module namespa... | 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 |
# 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.3... | 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.signup 'signup', :controller => 'users', :action => 'new'
map.logout 'logout', :controller => 'user_sessions', :action => 'destroy'
map.login 'login', :controller => 'user_sessions', :action => 'new'
map.resources :user_sessions
map.resources :users ... | Ruby |
atom_feed do |feed|
feed.title( 'Nami\'s blog' )
feed.updated(@articles.first.created_at)
@articles.each do |article|
feed.entry(article) do |entry|
entry.title(article.name)
entry.content(article.content, :type => 'html')
entry.author(article.author_name)
end
end
end | Ruby |
module ArticlesHelper
end
| Ruby |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
end
| Ruby |
module UsersHelper
end
| Ruby |
module UserSessionsHelper
end
| Ruby |
# These helper methods can be called in your template to set variables to be used in the layout
# This module should be included in all views globally,
# to do so you may need to add this line to your ApplicationController
# helper :layout
module LayoutHelper
def title(page_title, show_title = true)
@content_fo... | Ruby |
module CommentsHelper
end
| Ruby |
class Assignment < ActiveRecord::Base
belongs_to :user
belongs_to :role
end
| Ruby |
class Article < ActiveRecord::Base
has_many :comments, :dependent => :destroy
validates_presence_of :name, :content
belongs_to :user
end
| Ruby |
class User < ActiveRecord::Base
acts_as_authentic
has_many :articles
has_many :comments
named_scope :with_role, lambda { |role| {:conditions => "roles_mask & #{2**ROLES.index(role.to_s)} > 0"} }
ROLES = %w[admin moderator author]
def roles=(roles)
self.roles_mask = (roles & ROLES).map { |r| 2**... | Ruby |
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new # guest user
if user.role? :admin
can :manage, :all
else
can :read, :all
can :create, Comment
can :update, Comment do |comment|
comment.try(:user) == user || user.role?(:moderator)
... | Ruby |
class Comment < ActiveRecord::Base
belongs_to :article
belongs_to :user
validates_presence_of :author_name, :content
attr_protected :article_id
end
| Ruby |
class UserSession < Authlogic::Session::Base
end
| Ruby |
class Role < ActiveRecord::Base
has_many :assignments
has_many :users, :through => :assignments
end
| Ruby |
class UserSessionsController < ApplicationController
def new
@user_session = UserSession.new
end
def create
@user_session = UserSession.new(params[:user_session])
if @user_session.save
flash[:notice] = "Logged in successfully."
redirect_to_target_or_default(root_url)
else
rend... | Ruby |
class CommentsController < ApplicationController
load_and_authorize_resource
def new
end
def create
@comment.user = current_user
if @comment.save
flash[:notice] = "Successfully created comment."
redirect_to article_url(@comment.article_id)
else
render :action => 'new'
end... | Ruby |
class ArticlesController < ApplicationController
load_and_authorize_resource
def index
@articles = Article.paginate(:per_page => 3, :page => params[:page], :order => 'created_at DESC').reverse
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @articles }
... | 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 Authentication
helper :all
protect_from_forgery
rescue_from CanCan::AccessDenied do |exception|
... | Ruby |
class UsersController < ApplicationController
def new
@user = User.new
end
def create
@user = User.new(params[:user])
if @user.save
flash[:notice] = "Thank you for signing up! You are now logged in."
redirect_to root_url
else
render :action => 'new'
end
end
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/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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.