code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
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 |
# 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 |
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?
respond_to do |type|
type.html { render :action => 'show', :layout => true }
type.js { render :partial => 'show... | 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 containing the methods useful for child IFRAME to parent window communication
module RespondsToParent
# Executes the response body as JavaScript in the context of the parent window.
# Use this method of you are posting a form to a hidden IFRAME or if you would like
# to use IFRAME base RPC.
def resp... | 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
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 :nam... | 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')
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 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 File.dirname(__FILE__) + '/model_stub'
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 |
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
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
# easy way to include ActiveScaffold assets
def active_scaffold_includes
js = ActiveScaffold::Config::Core.javascripts.collect do |name|
javascript_include_tag(ActiveScaffold::Config::Core.asset_path(:javascript, name))
end.join... | 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)
return render(:partial => form_partial_for_column(column), :locals => { :column => column })
end
def form_partial_for_column(column)
if override_form_field_partial?(column)
ove... | 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
# Provides validation and template for displaying association in sub-list
def add_association
@association = active_scaffold_config.model.reflect_on_asso... | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.