code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
module ActiveScaffold::DataStructures
class Columns
include Enumerable
include ActiveScaffold::Configurable
# The motivation for this collection is that this Columns data structure fills two roles: it provides
# the master list of all known columns, and it provides an inheritable list for all other a... | Ruby |
module ActiveScaffold::DataStructures
class Set
include Enumerable
include ActiveScaffold::Configurable
attr_writer :label
def label
as_(@label)
end
def initialize(*args)
@set = []
self.add *args
end
# the way to add items to the set.
def add(*args)
args.... | Ruby |
module ActiveScaffold::DataStructures
class Column
include ActiveScaffold::Configurable
attr_reader :active_record_class
# this is the name of the getter on the ActiveRecord model. it is the only absolutely required attribute ... all others will be inferred from this name.
attr_accessor :name
#... | Ruby |
module ActiveScaffold::DataStructures
# A set of columns. These structures can be nested for organization.
class ActionColumns < Set
include ActiveScaffold::Configurable
# this lets us refer back to the action responsible for this link, if it exists.
# the immediate need here is to get the crud_type so... | Ruby |
class ActiveScaffold::DataStructures::Actions
include Enumerable
def initialize(*args)
@set = []
self.add *args
end
def exclude(*args)
args.collect! { |a| a.to_sym } # symbolize the args
@set.reject! { |m| args.include? m } # reject all actions specified
end
def add(*args)
args.each {... | Ruby |
module ActiveScaffold::DataStructures
class ActionLink
# provides a quick way to set any property of the object from a hash
def initialize(action, options = {})
# set defaults
self.action = action.to_s
self.label = action.to_s
self.confirm = false
self.type = :table
self.in... | Ruby |
module ActiveScaffold::DataStructures
# Wrapper for error strings so that they may be exported using to_xxx
class ErrorMessage
def initialize(error)
@error = error
end
def public_attributes
{ :error => @error }
end
def to_xml
public_attributes.to_xml(:root => "errors")
en... | Ruby |
require File.join(File.dirname(__FILE__), '../test_helper.rb')
class ArrayTest < Test::Unit::TestCase
def test_after
@sequence = ['a', 'b', 'c']
assert_equal 'b', @sequence.after('a')
assert_equal 'c', @sequence.after('b')
assert_equal 'a', @sequence.after('c')
assert_equal nil, @sequence.after(... | Ruby |
require File.join(File.dirname(__FILE__), '../test_helper.rb')
class PermissionModel < ActiveRecord::Base
def self.columns; [] end
def authorized_for_read?; true; end
def authorized_for_update?; false; end
#def authorized_for_create?; end
def a1_authorized?; true; end
def a2_authorized?; false; end
#de... | Ruby |
class ConstMocker
def initialize(*const_names)
@const_names = const_names
@const_states = {}
@const_names.each{|const_name|
@const_states[const_name] = Object.const_defined?(const_name) ? Object.const_get(const_name) : nil
}
end
def remove
@const_names.each{|const_name|
Object.s... | Ruby |
class ModelStub < ActiveRecord::Base
abstract_class = true
has_one :other_model, :class_name => 'ModelStub'
has_many :other_models, :class_name => 'ModelStub'
cattr_accessor :stubbed_columns
self.stubbed_columns = [:a, :b, :c, :d, :id]
attr_accessor *self.stubbed_columns
def other_model=(val)
@oth... | Ruby |
test_folders = %w[bridges config data_structures extensions misc]
all_tests = test_folders.inject([]) {|output, folder|
output + Dir[File.join(File.dirname(__FILE__), "#{folder}/**/*.rb")]
}
all_tests.each{|filename|
require filename
} | Ruby |
require 'test/unit'
require File.expand_path(File.join(File.dirname(__FILE__), '../../../../config/environment.rb'))
for file in %w[model_stub const_mocker]
require File.join(File.dirname(__FILE__), file)
end
ModelStub.connection.instance_eval do
def quote_column_name(name)
name
end
end | Ruby |
##
## Initialize the environment
##
require File.dirname(__FILE__) + '/environment'
##
## Run the install script, too, just to make sure
##
require File.dirname(__FILE__) + '/install'
| Ruby |
require 'rake'
require 'rake/testtask'
require 'rake/packagetask'
require 'rake/rdoctask'
require 'find'
desc 'Default: run unit tests.'
task :default => :test
desc 'Test ActiveScaffold.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
desc 'Generate docume... | Ruby |
require 'exceptions'
##
## Check for dependencies
##
version = Rails::VERSION::STRING.split(".")
if version[0] < "1" or (version[0] == "1" and version[1] < "2")
message = <<-EOM
************************************************************************
Rails 1.2.1 or greater is required. Please remove ActiveSc... | Ruby |
##
## Delete public asset files
##
require 'fileutils'
directory = File.dirname(__FILE__)
[ :stylesheets, :javascripts, :images].each do |asset_type|
path = File.join(directory, "../../../public/#{asset_type}/active_scaffold")
FileUtils.rm_r(path)
end | Ruby |
##
## Copy over asset files (javascript/css/images) from the plugin directory to public/
##
def copy_files(source_path, destination_path, directory)
source, destination = File.join(directory, source_path), File.join(RAILS_ROOT, destination_path)
FileUtils.mkdir(destination) unless File.exist?(destination)
FileUt... | Ruby |
module ActiveScaffold::Config
class Core < Base
# global level configuration
# --------------------------
# provides read/write access to the global Actions DataStructure
cattr_reader :actions
def self.actions=(val)
@@actions = ActiveScaffold::DataStructures::Actions.new(*val)
end
s... | Ruby |
module ActiveScaffold::Config
class Delete < Base
self.crud_type = :destroy
def initialize(core_config)
@core = core_config
# start with the ActionLink defined globally
@link = self.class.link.clone
end
# global level configuration
# --------------------------
# the Actio... | Ruby |
module ActiveScaffold::Config
class Subform < Base
def initialize(core_config)
@core = core_config
end
# global level configuration
# --------------------------
# instance-level configuration
# ----------------------------
# provides access to the list of columns specifically mean... | Ruby |
module ActiveScaffold::Config
class Create < Form
self.crud_type = :create
def initialize(*args)
super
self.persistent = self.class.persistent
end
# global level configuration
# --------------------------
# the ActionLink for this action
def self.link
@@link
end
... | Ruby |
module ActiveScaffold::Config
class Nested < Base
self.crud_type = :read
def initialize(core_config)
@core = core_config
end
# global level configuration
# --------------------------
# instance-level configuration
# ----------------------------
# Add a nested ActionLink
d... | Ruby |
module ActiveScaffold::Config
class Update < Form
self.crud_type = :update
# global level configuration
# --------------------------
# the ActionLink for this action
def self.link
@@link
end
def self.link=(val)
@@link = val
end
@@link = ActiveScaffold::DataStructures::... | Ruby |
module ActiveScaffold::Config
class FieldSearch < Base
self.crud_type = :read
def initialize(core_config)
@core = core_config
@full_text_search = self.class.full_text_search?
end
# global level configuration
# --------------------------
# the ActionLink for this action
catt... | Ruby |
module ActiveScaffold::Config
class Show < Base
self.crud_type = :read
def initialize(core_config)
@core = core_config
# start with the ActionLink defined globally
@link = self.class.link.clone
end
# global level configuration
# --------------------------
cattr_accessor :l... | Ruby |
module ActiveScaffold::Config
class List < Base
self.crud_type = :read
def initialize(core_config)
@core = core_config
# inherit from global scope
# full configuration path is: defaults => global table => local table
@per_page = self.class.per_page
# originates here
defa... | Ruby |
module ActiveScaffold::Config
class Search < Base
self.crud_type = :read
def initialize(core_config)
@core = core_config
@full_text_search = self.class.full_text_search?
end
# global level configuration
# --------------------------
# the ActionLink for this action
cattr_ac... | Ruby |
module ActiveScaffold::Config
class Form < Base
def initialize(core_config)
@core = core_config
# start with the ActionLink defined globally
@link = self.class.link.clone
# no global setting here because multipart should only be set for specific forms
@multipart = false
end
... | Ruby |
module ActiveScaffold::Config
class Base
include ActiveScaffold::Configurable
extend ActiveScaffold::Configurable
# the crud type of the action. possible values are :create, :read, :update, :destroy, and nil.
# this is not a setting for the developer. it's self-description for the actions.
def se... | Ruby |
module ActiveScaffold::Config
class LiveSearch < Base
self.crud_type = :read
def initialize(core_config)
@core = core_config
@full_text_search = self.class.full_text_search?
end
# global level configuration
# --------------------------
# the ActionLink for this action
cattr... | Ruby |
# wrap the action rendering for ActiveScaffold views
module ActionView #:nodoc:
class Base
# Adds two rendering options.
#
# ==render :super
#
# This syntax skips all template overrides and goes directly to the provided ActiveScaffold templates.
# Useful if you want to wrap an existing templat... | Ruby |
class Array
# returns the value after the given value. wraps around. defaults to first element in array.
def after(value)
return nil unless include? value
self[(index(value).to_i + 1) % length]
end
end | Ruby |
# wrap the action rendering for ActiveScaffold controllers
module ActionController #:nodoc:
class Base
def render_with_active_scaffold(*args, &block)
if self.class.uses_active_scaffold? and params[:adapter] and @rendering_adapter.nil?
@rendering_adapter = true # recursion control
# if we nee... | Ruby |
module ActionController
module Resources
class Resource
# by overwriting the attr_reader :options, we can parse out a special :active_scaffold flag just-in-time.
def options
if @options.delete :active_scaffold
logger.info "ActiveScaffold: extending RESTful routes for #{@plural}"
... | Ruby |
class ActiveRecord::Base
def to_label
[:name, :label, :title, :to_s].each do |attribute|
return send(attribute) if respond_to?(attribute) and send(attribute).is_a?(String)
end
end
def associated_valid?
with_instantiated_associated {|a| a.valid? and a.associated_valid?}
end
def no_errors_i... | Ruby |
# Apply patch (http://dev.rubyonrails.org/changeset/6343) that is already in edge, soon to be 1.2.4
# Allow array and hash query parameters. Array route parameters are converted/to/a/path as before. #6765, #7047, #7462 [bgipsy, Jeremy McAnally, Dan Kubb, brendan]
module ActionController
module Routing
class Rout... | Ruby |
require 'forwardable'
class Paginator
VERSION = '1.0.9'
class ArgumentError < ::ArgumentError; end
class MissingCountError < ArgumentError; end
class MissingSelectError < ArgumentError; end
attr_reader :per_page, :count
# Instantiate a new Paginator object
#
# Provide:
# * A total count ... | Ruby |
module ActiveScaffold
def self.included(base)
base.extend(ClassMethods)
base.module_eval do
# TODO: these should be in actions/core
before_filter :handle_user_settings
end
end
def self.set_defaults(&block)
ActiveScaffold::Config::Core.configure &block
end
def active_... | Ruby |
module ActionView::Helpers
module ActiveScaffoldHelpers
def active_scaffold_config_for(*args)
@controller.class.active_scaffold_config_for(*args)
end
def active_scaffold_controller_for(*args)
@controller.class.active_scaffold_controller_for(*args)
end
# easy way to include ... | Ruby |
module ActionView::Helpers
# A bunch of helper methods to produce the common view ids
module ActiveScaffoldIdHelpers
def controller_id
@controller_id ||= params[:controller].gsub("/", "__")
end
def active_scaffold_id
"#{controller_id}-active-scaffold"
end
def active_scaf... | Ruby |
module ActionView::Helpers
module ActiveScaffoldFormHelpers
def render_form_field_for_column(column, locals = {})
locals[:column] = column
return render(:partial => form_partial_for_column(column), :locals => locals)
end
def is_subform?(column)
column_renders_as(column) == :subf... | Ruby |
module ActionView::Helpers
module ActiveScaffoldListHelpers
def render_action_link(link, url_options)
url_options = url_options.clone
url_options[:action] = link.action
url_options.merge! link.parameters if link.parameters
# NOTE this is in url_options instead of html_options on pu... | Ruby |
module ActiveScaffold
module Constraints
def self.included(base)
base.module_eval do
before_filter :register_constraints_with_action_columns
end
end
protected
# Returns the current constraints
def active_scaffold_constraints
return active_scaffold_session_storage[:const... | Ruby |
module ActiveScaffold
# Provides support for param hashes assumed to be model attributes.
# Support is primarily needed for creating/editing associated records using a nested hash structure.
#
# Paradigm Params Hash (should write unit tests on this):
# params[:record] = {
# # a simple record attribute... | Ruby |
module ActiveScaffold::Actions
module Core
def self.included(base)
base.class_eval do
after_filter :clear_flashes
end
end
protected
def authorized_for?(*args)
active_scaffold_config.model.authorized_for?(*args)
end
def clear_flashes
if request.xhr?
fl... | Ruby |
module ActiveScaffold::Actions
module Delete
def self.included(base)
base.before_filter :delete_authorized?, :only => [:delete, :destroy]
end
# this method is for html mode. it provides "the missing action" (http://thelucid.com/articles/2006/07/26/simply-restful-the-missing-action).
# it also g... | Ruby |
module ActiveScaffold::Actions
module Subform
def edit_associated
@parent_record = params[:id].nil? ? active_scaffold_config.model.new : find_if_allowed(params[:id], :update)
@column = active_scaffold_config.columns[params[:association]]
# NOTE: we don't check whether the user is allowed to upd... | Ruby |
module ActiveScaffold::Actions
module Create
def self.included(base)
base.before_filter :create_authorized?, :only => [:new, :create]
base.verify :method => :post,
:only => :create,
:redirect_to => { :action => :index }
end
def new
do_new
respo... | Ruby |
module ActiveScaffold::Actions
module Nested
def self.included(base)
super
base.active_scaffold_config.list.columns.each do |column|
column.set_link('nested', :parameters => {:associations => column.name.to_sym}) if column.association and column.link.nil? and column.plural_association?
... | Ruby |
module ActiveScaffold::Actions
module Update
def self.included(base)
base.before_filter :update_authorized?, :only => [:edit, :update]
base.verify :method => [:post, :put],
:only => :update,
:redirect_to => { :action => :index }
end
def edit
do_edit
... | Ruby |
module ActiveScaffold::Actions
module FieldSearch
def self.included(base)
base.before_filter :field_search_authorized?, :only => :show_search
base.before_filter :do_search
end
# FieldSearch uses params[:search] and not @record because search conditions do not always pass the Model's validatio... | Ruby |
module ActiveScaffold::Actions
module Show
def self.included(base)
base.before_filter :show_authorized?, :only => :show
end
def show
do_show
@successful = successful?
respond_to do |type|
type.html { render :action => 'show', :layout => true }
type.js { render :pa... | Ruby |
module ActiveScaffold::Actions
module List
def self.included(base)
base.before_filter :list_authorized?, :only => [:index, :table, :update_table, :row, :list]
end
def index
list
end
def table
do_list
render(:action => 'list', :layout => false)
end
# This is calle... | Ruby |
module ActiveScaffold::Actions
module Search
def self.included(base)
base.before_filter :search_authorized?, :only => :show_search
base.before_filter :do_search
end
def show_search
respond_to do |type|
type.html do
if successful?
render(:partial => "search"... | Ruby |
module ActiveScaffold::Actions
module LiveSearch
def self.included(base)
base.before_filter :live_search_authorized?, :only => :show_search
base.before_filter :do_search
end
def show_search
respond_to do |type|
type.html do
if successful?
render(:partial =>... | Ruby |
module ActiveScaffold
class ControllerNotFound < RuntimeError; end
class DependencyFailure < RuntimeError; end
class MalformedConstraint < RuntimeError; end
class RecordNotAllowed < SecurityError; end
end
| Ruby |
module ActiveScaffold
# Exposes a +configure+ method that accepts a block and runs all contents of the block in two contexts, as opposed to the normal one. First, everything gets evaluated as part of the object including Configurable. Then, as a failover, missing methods and variables are evaluated in the original bi... | Ruby |
module ActiveScaffold
module Finder
def self.create_conditions_for_columns(tokens, columns, like_pattern = '%?%')
tokens = [tokens] if tokens.is_a? String
where_clauses = []
columns.each do |column|
where_clauses << "LOWER(#{column.search_sql}) LIKE ?"
end
phrase = "(#{where... | Ruby |
# This module attempts to create permissions conventions for your ActiveRecord models. It supports english-based
# methods that let you restrict access per-model, per-record, per-column, per-action, and per-user. All at once.
#
# You may define instance methods in the following formats:
# def #{column}_authorized_for_... | Ruby |
module ActiveScaffold::DataStructures
# encapsulates the column sorting configuration for the List view
class Sorting
include Enumerable
def initialize(columns)
@columns = columns
@clauses = []
end
# add a clause to the sorting, assuming the column is sortable
def add(column_name, ... | Ruby |
module ActiveScaffold::DataStructures
class ActionLinks
include Enumerable
def initialize
@set = []
end
# adds an ActionLink, creating one from the arguments if need be
def add(action, options = {})
link = action.is_a?(ActiveScaffold::DataStructures::ActionLink) ? action : ActiveScaf... | Ruby |
module ActiveScaffold::DataStructures
class Columns
include Enumerable
include ActiveScaffold::Configurable
# This accessor is used by ActionColumns to create new Column objects without adding them to this set
attr_reader :active_record_class
def initialize(active_record_class, *args)
@act... | Ruby |
module ActiveScaffold::DataStructures
class Set
include Enumerable
include ActiveScaffold::Configurable
attr_writer :label
def label
as_(@label)
end
def initialize(*args)
@set = []
self.add *args
end
# the way to add items to the set.
def add(*args)
args.... | Ruby |
module ActiveScaffold::DataStructures
class Column
include ActiveScaffold::Configurable
# this is the name of the getter on the ActiveRecord model. it is the only absolutely required attribute ... all others will be inferred from this name.
attr_accessor :name
# the display-name of the column. this ... | Ruby |
module ActiveScaffold::DataStructures
# A set of columns. These structures can be nested for organization.
class ActionColumns < Set
include ActiveScaffold::Configurable
# this lets us refer back to the action responsible for this link, if it exists.
# the immediate need here is to get the crud_type so... | Ruby |
class ActiveScaffold::DataStructures::Actions
include Enumerable
def initialize(*args)
@set = []
self.add *args
end
def exclude(*args)
args.collect! { |a| a.to_sym } # symbolize the args
@set.reject! { |m| args.include? m } # reject all actions specified
end
def add(*args)
args.each {... | Ruby |
module ActiveScaffold::DataStructures
class ActionLink
# provides a quick way to set any property of the object from a hash
def initialize(action, options = {})
# set defaults
self.action = action
self.label = action
self.confirm = false
self.type = :table
self.inline = tru... | Ruby |
module ActiveScaffold::DataStructures
# Wrapper for error strings so that they may be exported using to_xxx
class ErrorMessage
def initialize(error)
@error = error
end
def public_attributes
{ :error => @error }
end
def to_xml
public_attributes.to_xml(:root => "errors")
en... | Ruby |
require File.join(File.dirname(__FILE__), '../test_helper.rb')
def ArrayTest < Test::Unit::TestCase
def test_after
@sequence = ['a', 'b', 'c']
assert_equal 'b', @sequence.after('a')
assert_equal 'c', @sequence.after('b')
assert_equal 'a', @sequence.after('c')
assert_equal nil, @sequence.after('d... | Ruby |
require File.join(File.dirname(__FILE__), '../test_helper.rb')
class PermissionModel < ActiveRecord::Base
def self.columns; [] end
def authorized_for_read?; true; end
def authorized_for_update?; false; end
#def authorized_for_create?; end
def a1_authorized?; true; end
def a2_authorized?; false; end
#de... | Ruby |
class ModelStub < ActiveRecord::Base
abstract_class = true
has_one :other_model, :class_name => 'ModelStub'
has_many :other_models, :class_name => 'ModelStub'
attr_accessor :a, :b, :c, :d
def other_model=(val)
@other_model = val
end
def other_model
@other_model || nil
end
def other_models=(v... | Ruby |
require 'test/unit'
require File.expand_path(File.join(File.dirname(__FILE__), '../../../../config/environment.rb'))
require 'rubygems'
require 'action_controller'
require 'action_view'
require 'active_support'
require 'active_record'
$LOAD_PATH << File.dirname(__FILE__) + '/../lib/'
require File.dirname(__FILE__) +... | Ruby |
##
## Initialize the environment
##
require File.dirname(__FILE__) + '/environment'
##
## Run the install script, too, just to make sure
##
require File.dirname(__FILE__) + '/install'
| Ruby |
require 'rake'
require 'rake/testtask'
require 'rake/packagetask'
require 'rake/rdoctask'
require 'find'
desc 'Default: run unit tests.'
task :default => :test
desc 'Test ActiveScaffold.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
desc 'Generate docume... | Ruby |
require 'exceptions'
##
## Check for dependencies
##
version = Rails::VERSION::STRING.split(".")
if version[0] < "1" or (version[0] == "1" and version[1] < "2")
message = <<-EOM
************************************************************************
Rails 1.2.1 or greater is required. Please remove ActiveSc... | Ruby |
##
## Delete public asset files
##
require 'fileutils'
directory = File.dirname(__FILE__)
[ :stylesheets, :javascripts, :images].each do |asset_type|
path = File.join(directory, "../../../public/#{asset_type}/active_scaffold")
FileUtils.rm_r(path)
end | Ruby |
# Workaround a problem with script/plugin and http-based repos.
# See http://dev.rubyonrails.org/ticket/8189
Dir.chdir(Dir.getwd.sub(/vendor.*/, '')) do
##
## Copy over asset files (javascript/css/images) from the plugin directory to public/
##
def copy_files(source_path, destination_path, directory)
source, destin... | Ruby |
module ActiveScaffold::Config
class Core < Base
# global level configuration
# --------------------------
# provides read/write access to the global Actions DataStructure
cattr_reader :actions
def self.actions=(val)
@@actions = ActiveScaffold::DataStructures::Actions.new(*val)
end
s... | Ruby |
module ActiveScaffold::Config
class Delete < Base
self.crud_type = :destroy
def initialize(core_config)
@core = core_config
# start with the ActionLink defined globally
@link = self.class.link.clone
end
# global level configuration
# --------------------------
# the Actio... | Ruby |
module ActiveScaffold::Config
class Subform < Base
def initialize(core_config)
@core = core_config
end
# global level configuration
# --------------------------
# instance-level configuration
# ----------------------------
# provides access to the list of columns specifically mean... | Ruby |
module ActiveScaffold::Config
class Create < Form
self.crud_type = :create
def initialize(*args)
super
self.persistent = self.class.persistent
end
# global level configuration
# --------------------------
# the ActionLink for this action
def self.link
@@link
end
... | Ruby |
module ActiveScaffold::Config
class Nested < Base
self.crud_type = :read
def initialize(core_config)
@core = core_config
end
# global level configuration
# --------------------------
# instance-level configuration
# ----------------------------
# Add a nested ActionLink
d... | Ruby |
module ActiveScaffold::Config
class Update < Form
self.crud_type = :update
# global level configuration
# --------------------------
# the ActionLink for this action
def self.link
@@link
end
def self.link=(val)
@@link = val
end
@@link = ActiveScaffold::DataStructures::... | Ruby |
module ActiveScaffold::Config
class FieldSearch < Base
self.crud_type = :read
def initialize(core_config)
@core = core_config
@full_text_search = self.class.full_text_search?
end
# global level configuration
# --------------------------
# the ActionLink for this action
catt... | Ruby |
module ActiveScaffold::Config
class Show < Base
self.crud_type = :read
def initialize(core_config)
@core = core_config
# start with the ActionLink defined globally
@link = self.class.link.clone
end
# global level configuration
# --------------------------
cattr_accessor :l... | Ruby |
module ActiveScaffold::Config
class List < Base
self.crud_type = :read
def initialize(core_config)
@core = core_config
# inherit from global scope
# full configuration path is: defaults => global table => local table
@per_page = self.class.per_page
# originates here
defa... | Ruby |
module ActiveScaffold::Config
class Search < Base
self.crud_type = :read
def initialize(core_config)
@core = core_config
@full_text_search = self.class.full_text_search?
end
# global level configuration
# --------------------------
# the ActionLink for this action
cattr_ac... | Ruby |
module ActiveScaffold::Config
class Form < Base
def initialize(core_config)
@core = core_config
# start with the ActionLink defined globally
@link = self.class.link.clone
# no global setting here because multipart should only be set for specific forms
@multipart = false
end
... | Ruby |
module ActiveScaffold::Config
class Base
include ActiveScaffold::Configurable
extend ActiveScaffold::Configurable
# the crud type of the action. possible values are :create, :read, :update, :destroy, and nil.
# this is not a setting for the developer. it's self-description for the actions.
def se... | Ruby |
module ActiveScaffold::Config
class LiveSearch < Base
self.crud_type = :read
def initialize(core_config)
@core = core_config
@full_text_search = self.class.full_text_search?
end
# global level configuration
# --------------------------
# the ActionLink for this action
cattr... | Ruby |
# wrap the action rendering for ActiveScaffold views
module ActionView #:nodoc:
class Base
# Adds two rendering options.
#
# ==render :super
#
# This syntax skips all template overrides and goes directly to the provided ActiveScaffold templates.
# Useful if you want to wrap an existing templat... | Ruby |
class ActionController::Routing::RouteSet
def generate_with_nil_id_awareness(*args)
args[0].delete(:id) if args[0][:id].nil?
generate_without_nil_id_awareness(*args)
end
alias_method_chain :generate, :nil_id_awareness
end | Ruby |
class Array
# returns the value after the given value. wraps around. defaults to first element in array.
def after(value)
return nil unless include? value
self[(index(value).to_i + 1) % length]
end
end | Ruby |
# wrap the action rendering for ActiveScaffold controllers
module ActionController #:nodoc:
class Base
def render_with_active_scaffold(*args, &block)
if self.class.uses_active_scaffold? and params[:adapter] and @rendering_adapter.nil?
@rendering_adapter = true # recursion control
# if we nee... | Ruby |
module ActionController
module Resources
class Resource
# by overwriting the attr_reader :options, we can parse out a special :active_scaffold flag just-in-time.
def options
if @options.delete :active_scaffold
logger.info "ActiveScaffold: extending RESTful routes for #{@plural}"
... | Ruby |
# the ever-useful to_label method
class ActiveRecord::Base
def to_label
[:name, :label, :title, :to_s].each do |attribute|
return send(attribute) if respond_to?(attribute) and send(attribute).is_a?(String)
end
end
end
# a simple (manual) unsaved? flag and method. at least it automatically reverts aft... | Ruby |
# Apply patch (http://dev.rubyonrails.org/changeset/6343) that is already in edge, soon to be 1.2.4
# Allow array and hash query parameters. Array route parameters are converted/to/a/path as before. #6765, #7047, #7462 [bgipsy, Jeremy McAnally, Dan Kubb, brendan]
module ActionController
module Routing
class Rout... | Ruby |
module ActiveRecord
module Reflection
class AssociationReflection #:nodoc:
def reverse_for?(klass)
reverse_matches_for(klass).empty? ? false : true
end
attr_writer :reverse
def reverse
unless @reverse
reverse_matches = reverse_matches_for(self.class_nam... | Ruby |
require 'forwardable'
class Paginator
VERSION = '1.0.9'
class ArgumentError < ::ArgumentError; end
class MissingCountError < ArgumentError; end
class MissingSelectError < ArgumentError; end
attr_reader :per_page, :count
# Instantiate a new Paginator object
#
# Provide:
# * A total count ... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.