lib/active_scaffold/bridges/record_select/helpers.rb
# requires RecordSelect plugin to be installed and configured.
requires RecordSelect plugin to be installed and configured.
requires RecordSelect plugin to be installed and configured .
def active_scaffold_record_select(record, column, options, value, multiple)
        unless column.association
          raise ArgumentError, "record_select can only work against associations (and #{column.name} is not). "\
          'A common mistake is to specify the foreign key field (like :user_id), instead of the association (:user).'
        end
        klass = column.association.klass(record)
        return content_tag :span, '', :class => options[:class] unless klass
        remote_controller = active_scaffold_controller_for(klass).controller_path
        if column.association.has_one? || column.association.has_many?
          params[column.association.foreign_key] = ''
        end
        record_select_options = active_scaffold_input_text_options(options).merge(
          :controller => remote_controller
        )
        record_select_options.merge!(column.options)
        html =
          if multiple
            record_multi_select_field(options[:name], value || [], record_select_options.except(:required))
          else
            record_select_field(options[:name], value || klass.new, record_select_options)
          end
        html = self.class.field_error_proc.call(html, self) if record.errors[column.name].any?
        html
      end
def active_scaffold_record_select ( record , column , options , value , multiple ) unless column . association raise ArgumentError , "record_select can only work against associations (and #{column.name} is not). " 'A common mistake is to specify the foreign key field (like :user_id), instead of the association (:user).' end klass = column . association . klass ( record ) return content_tag :span , '' , :class => options [ :class ] unless klass remote_controller = active_scaffold_controller_for ( klass ) . controller_path if column . association . has_one? || column . association . has_many? params [ column . association . foreign_key ] = '' end record_select_options = active_scaffold_input_text_options ( options ) . merge ( :controller => remote_controller ) record_select_options . merge! ( column . options ) html = if multiple record_multi_select_field ( options [ :name ] , value || [ ] , record_select_options . except ( :required ) ) else record_select_field ( options [ :name ] , value || klass . new , record_select_options ) end html = self . class . field_error_proc . call ( html , self ) if record . errors [ column . name ] . any? html end
requires RecordSelect plugin to be installed and configured.
requires RecordSelect plugin to be installed and configured .
# if the opposite association is a :belongs_to (in that case association in this class must be has_one or has_many) # then only show records that have not been associated yet
record
<not_specific>
column
<not_specific>
options
<not_specific>
value
<not_specific>
multiple
<not_specific>