Sha256: 00ba30029729f4da6151e136e30396508b0c83ae2ec9a93033b637396f867969

Contents?: true

Size: 1.2 KB

Versions: 9

Compression:

Stored size: 1.2 KB

Contents

module ActiveScaffold::Config
  class Nested < Base
    self.crud_type = :read

    def initialize(core_config)
      super
      @label = :add_existing_model
      self.shallow_delete = self.class.shallow_delete
      @action_group = self.class.action_group.clone if self.class.action_group
    end

    # global level configuration
    # --------------------------
    cattr_accessor :shallow_delete
    @@shallow_delete = true

    # instance-level configuration
    # ----------------------------
    attr_accessor :shallow_delete

    # Add a nested ActionLink
    def add_link(attribute, options = {})
      column = @core.columns[attribute.to_sym]
      unless column.nil? || column.association.nil?
        options.reverse_merge! :security_method => :nested_authorized?, :label => column.association.associated_class.model_name.human({:count => 2, :default => column.association.associated_class.name.pluralize}) 
        action_link = @core.link_for_association(column, options)
        action_link.action ||= :index
        @core.action_links.add_to_group(action_link, action_group) unless action_link.nil?
      end
    end

    # the label for this Nested action. used for the header.
    attr_writer :label
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
active_scaffold-sequel-0.8.0 lib/active_scaffold/config/nested.rb
active_scaffold-sequel-0.7.1 lib/active_scaffold/config/nested.rb
active_scaffold-sequel-0.7.0 lib/active_scaffold/config/nested.rb
active_scaffold-sequel-0.6.2 lib/active_scaffold/config/nested.rb
active_scaffold-sequel-0.6.1 lib/active_scaffold/config/nested.rb
active_scaffold-sequel-0.6.0 lib/active_scaffold/config/nested.rb
active_scaffold-sequel-0.5.1 lib/active_scaffold/config/nested.rb
active_scaffold-sequel-0.5.0 lib/active_scaffold/config/nested.rb
active_scaffold-sequel-0.4.0 lib/active_scaffold/config/nested.rb