code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
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
include ActiveScaffold::Configurable
attr_accessor :label
def initialize(*args)
@set = []
self.add *args
end
# the way to remove columns from the set.
... | 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 'test/test_helper'
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')
end
end | Ruby |
class ModelStub < ActiveRecord::Base
abstract_class = true
has_one :other_model
def self.columns
@columns ||= [
ActiveRecord::ConnectionAdapters::Column.new(:a, ''),
ActiveRecord::ConnectionAdapters::Column.new(:b, ''),
ActiveRecord::ConnectionAdapters::Column.new(:c, ''),
ActiveRecor... | Ruby |
require 'test/unit'
require 'rubygems'
require 'action_controller'
require 'action_view'
require 'active_support'
require 'active_record'
$LOAD_PATH << File.dirname(__FILE__) + '/../lib/'
require File.dirname(__FILE__) + '/../environment.rb' | Ruby |
##
## Initialize the environment
##
require File.dirname(__FILE__) + '/environment'
##
## Run the install script, too, just to make sure
##
require File.dirname(__FILE__) + '/install'
| Ruby |
Localization.define('he_HE') do |lang|
lang['ARE_YOU_SURE'] ||= '? האם אתה בטוח'
lang['CANCEL'] ||= 'בטל'
lang['CREATE'] ||= 'צור'
lang['CREATE_NEW'] ||= חדש'
lang['DELETE'] ||= 'מחק'
lang['EDIT'] ||= 'ערוך'
lang['NEXT'] ||= 'הבא'
lang['NO_ENTRIES'] ||= 'לא נמצא'
lang['PREVIOUS'] ||= 'קודם'
... | Ruby |
Localization.define('fr_FR') do |lang|
lang['ARE_YOU_SURE'] ||= 'Etes-vous sûr?'
lang['CANCEL'] ||= 'Annuler'
lang['CREATE'] ||= 'Créer'
lang['CREATE_NEW'] ||= 'Nouveau'
lang['DELETE'] ||= 'Effacer'
lang['EDIT'] ||= 'Editer'
lang['NEXT'] ||= 'Suivant'
lang['NO_ENTRIES'] ||= 'Aucune entrée'
la... | Ruby |
Localization.define('nb_NO') do |lang|
lang['ARE_YOU_SURE'] ||= 'Er du sikker?'
lang['CANCEL'] ||= 'Avbryt'
lang['CREATE'] ||= 'Opprett'
lang['CREATE_NEW'] ||= 'Opprett ny'
lang['DELETE'] ||= 'Slett'
lang['EDIT'] ||= 'Redigèr'
lang['NEXT'] ||= 'Neste'
lang['NO_ENTRIES'] ||= 'Ingen oppføringer'
lang['P... | Ruby |
Localization.define('en_US') do |lang|
lang['ARE_YOU_SURE'] ||= 'Are you sure?'
lang['CANCEL'] ||= 'Cancel'
lang['CREATE'] ||= 'Create'
lang['CREATED %s'] ||= 'Created %s'
lang['CREATE_NEW'] ||= 'Create New'
lang['DELETE'] ||= 'Delete'
lang['DELETED %s'] ||= 'Deleted %s'
lang['EDIT'] ||= 'Edit'
lang[... | Ruby |
Localization.define('de_DE') do |lang|
lang['ARE_YOU_SURE'] ||= 'Sind Sie sicher?'
lang['CANCEL'] ||= 'Abbrechen'
lang['CREATE'] ||= 'Erstellen'
lang['CREATE_NEW'] ||= 'Neu'
lang['DELETE'] ||= 'Löschen'
lang['EDIT'] ||= 'Bearbeiten'
lang['NEXT'] ||= 'Vor'
lang['NO_ENTRIES'] ||= 'Keine Daten vorh... | Ruby |
Localization.define('nl_NL') do |lang|
lang['ARE_YOU_SURE'] ||= 'Weet u het zeker?'
lang['CANCEL'] ||= 'Annuleren'
lang['CREATE'] ||= 'Toevoegen'
lang['CREATE_NEW'] ||= 'Nieuw'
lang['DELETE'] ||= 'Verwijderen'
lang['EDIT'] ||= 'Bewerken'
lang['NEXT'] ||= 'Volgende'
lang['NO_ENTRIES'] ||= 'Geen d... | Ruby |
Localization.define('es_AR') do |lang|
lang['ARE_YOU_SURE'] ||= '¿Está seguro?'
lang['CANCEL'] ||= 'Cancelar'
lang['CREATE'] ||= 'Crear'
lang['CREATE_NEW'] ||= 'Crear Nuevo'
lang['DELETE'] ||= 'Eliminar'
lang['EDIT'] ||= 'Editar'
lang['NEXT'] ||= 'Siguiente'
lang['NO_ENTRIES'] ||= 'No hay entrad... | Ruby |
Localization.define('ru_RU') do |lang|
lang['ARE_YOU_SURE'] ||= 'Вы уверены?'
lang['CANCEL'] ||= 'Отмена'
lang['CREATE'] ||= 'Создать'
lang['CREATE_NEW'] ||= 'Новая запись'
lang['DELETE'] ||= 'Удалить'
lang['EDIT'] ||= 'Изменить'
lang['NEXT'] ||= 'Следующая'
lang['NO_ENTRIES'] ||= 'Нет записей' ... | 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 |
##
## Check for dependencies
##
begin
Paginator rescue require('paginator')
rescue NameError, MissingSourceFile
message = <<-EOM
************************************************************************
Paginator gem is required! Try `sudo gem install paginator`,'
or see http://rubyforge.org/projects/pag... | 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
def initialize(core_config)
@core = core_config
# start with the ActionLink defined globally
@link = self.class.link.clone
end
# global level configuration
# --------------------------
# the ActionLink for this action
cattr... | Ruby |
module ActiveScaffold::Config
class Create < Form
# global level configuration
# --------------------------
# the ActionLink for this action
def self.link
@@link
end
def self.link=(val)
@@link = val
end
@@link = ActiveScaffold::DataStructures::ActionLink.new('new', :label =... | Ruby |
module ActiveScaffold::Config
class Nested < Base
def initialize(core_config)
@core = core_config
end
# global level configuration
# --------------------------
# Add a nested ActionLink
def add_link(label, models)
@core.action_links.add('nested', :label => label, :type => :record... | Ruby |
module ActiveScaffold::Config
class Update < Form
# global level configuration
# --------------------------
# the ActionLink for this action
def self.link
@@link
end
def self.link=(val)
@@link = val
end
@@link = ActiveScaffold::DataStructures::ActionLink.new('edit', :label ... | Ruby |
module ActiveScaffold::Config
class Show < Base
def initialize(core_config)
@core = core_config
# inherit from the core's list of columns.
self.columns = @core.columns.collect{|c| c.name}
# start with the ActionLink defined globally
@link = self.class.link.clone
end
# glob... | Ruby |
module ActiveScaffold::Config
class List < Base
def initialize(core_config)
@core = core_config
# inherit from the core's list of columns.
self.columns = @core.columns.collect{|c| c.name}
# inherit from global scope
# full configuration path is: defaults => global table => local ta... | Ruby |
module ActiveScaffold::Config
class Search < Base
def initialize(core_config)
@core = core_config
# inherit searchable columns from the core's list of columns
self.columns = @core.columns.collect{|c| c.name if c.searchable?and (c.column.type == :string or c.column.type == :text)}.compact
en... | 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
# inherit from the core's list of columns, but exclude a few extra fields by default
self.columns = @core.colum... | Ruby |
module ActiveScaffold::Config
class Base
include ActiveScaffold::Configurable
extend ActiveScaffold::Configurable
# the user property gets set to the instantiation of the local UserSettings class during the automatic instantiation of this class.
attr_accessor :user
class UserSettings
def i... | Ruby |
module ActiveScaffold::Config
class LiveSearch < Base
def initialize(core_config)
@core = core_config
# inherit searchable columns from the core's list of columns
self.columns = @core.columns.collect{|c| c.name if c.searchable? and (c.column.type == :string or c.column.type == :text)}.compact
... | Ruby |
# wrap the action rendering for ActiveScaffold views
module ActionView #:nodoc:
class Base
def render_with_active_scaffold(*args)
if args.first == :super
template_path = caller.first.split(':').first
template = File.basename(template_path)
ActiveScaffold::Config::Core.template_searc... | 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
end
end
end | Ruby |
module ActiveScaffold
module FormAssociations
protected
# Takes attributes (as from params[:record]) and applies them to the parent_record. Also looks for
# association attributes and attempts to instantiate them as associated objects.
#
# This is a secure way to apply params to a record, because... | Ruby |
module ActiveScaffold
def self.included(base)
base.extend(ClassMethods)
base.module_eval do
before_filter :handle_user_settings
before_filter :handle_column_constraints
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_... | 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 form_partial_for_column(column)
if override_form_field... | Ruby |
module ActionView::Helpers
module ActiveScaffoldListHelpers
# checks whether the given action_link is allowed for the given record
def record_is_allowed_for_link(record, link)
return true unless record.respond_to? link.security_method
current_user = controller.send(active_scaffold_config.curr... | Ruby |
module ActiveScaffold::Actions
module Core
def self.included(base)
base.class_eval do
after_filter :clear_flashes
end
end
protected
def clear_flashes
if request.xhr?
flash.keys.each do |flash_key|
flash[flash_key] = nil
end
end
end
#... | Ruby |
module ActiveScaffold::Actions
module Delete
include Base
# 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 gives us delete confirmation for html mode. woo!
def delete
insulate { do_delete }
... | Ruby |
module ActiveScaffold::Actions
module Create
include Base
def self.included(base)
super
base.verify :method => :post,
:only => :create,
:redirect_to => { :action => :index }
end
def new
insulate { do_new }
respond_to do |type|
type... | 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 [:has_many, :has_and_belongs_to_m... | Ruby |
module ActiveScaffold::Actions
module Update
include Base
def self.included(base)
super
base.verify :method => [:post, :put],
:only => :update,
:redirect_to => { :action => :index }
end
def edit
insulate { do_edit }
respond_to do |type|
... | Ruby |
module ActiveScaffold::Actions
module Show
include ActiveScaffold::Actions::Base
def show
insulate { do_show }
@successful = successful?
respond_to do |type|
type.html { render :action => 'show', :layout => true }
type.js { render :partial => 'show', :layout => false }
... | Ruby |
module ActiveScaffold::Actions
module List
include ActiveScaffold::Actions::Base
def index
list
end
def table
do_list
render(:action => 'list', :layout => false)
end
# This is called when changing pages, sorts and search
def update_table
respond_to do |type|
... | Ruby |
module ActiveScaffold::Actions
module Search
include ActiveScaffold::Actions::Base
def self.included(base)
base.before_filter :do_search
end
def show_search
respond_to do |type|
type.html do
if successful?
render(:partial => "search", :layout => true)
... | Ruby |
module ActiveScaffold::Actions
# every action gets basic security control for free. this is accomplished by
# placing a before_filter on each public method of the action which calls a
# method that can be overwritten by the developer to enable security controls.
# the method is named #{action}_authorized?, and ... | Ruby |
module ActiveScaffold::Actions
module LiveSearch
include ActiveScaffold::Actions::Base
def self.included(base)
base.before_filter :do_search
end
def show_search
respond_to do |type|
type.html do
if successful?
render(:partial => "live_search", :layout => true... | 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 Localization
mattr_accessor :lang
@@l10s = { :default => {} }
@@lang = :default
def self._(string_to_localize, *args)
if @@l10s[@@lang].nil? or @@l10s[@@lang][string_to_localize].nil?
translated = string_to_localize
else
translated = @@l10s[@@lang][string_to_localize]
end
... | 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 |
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 = {})
if action.is_a? ActiveScaffold::DataStructures::ActionLink
@set << action
... | Ruby |
module ActiveScaffold::DataStructures
class Columns
include Enumerable
include ActiveScaffold::Configurable
attr_reader :unauthorized_columns
# This accessor is used by ActionColumns to create new Column objects without adding them to this set
attr_reader :active_record_class
def initialize... | 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
include ActiveScaffold::Configurable
attr_accessor :label
def initialize(*args)
@set = []
self.add *args
end
# the way to remove columns from the set.
... | 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 'test/test_helper'
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')
end
end | 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 'rubygems'
require 'action_controller'
require 'action_view'
require 'active_support'
require 'active_record'
$LOAD_PATH << File.dirname(__FILE__) + '/../lib/'
require File.dirname(__FILE__) + '/../environment.rb' | 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
def self.inherited(subclass)
class << subclass
# the crud type of the action. possible values are :create, :read, :update, :destroy, and nil.
# this is not a setting for... | 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 |
# Matt Mower <matt@cominded.com>
#
# A base class for creating DHTML confirmation types.
#
# The real work is done by the onclick_function and onclick_handler methods. In
# general it should only be required to override the default onclick_handler
# method and provide the specific Javascript required to invoke the DHT... | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.