Sha256: b05fff8a2df7b131effb4079eb7a145e6d3b476a95cd7e021102a4425c46bef9

Contents?: true

Size: 598 Bytes

Versions: 4

Compression:

Stored size: 598 Bytes

Contents

# Makes certain AR Model methods available to the view model.
#
# Useful when the model is an AR Model.
#
module ViewModels
  module Extensions
    module ActiveRecord
      
      # id and param are simply delegated to the model.
      #
      # This makes it possible to use the view_model
      # for e.g. url generation:
      # * edit_user_path(view_model)
      #
      delegate :id, :to_param, :to => :model
      
      # Delegate to the action controller record identifier.
      #
      def dom_id
        ActionController::RecordIdentifier.dom_id model
      end
      
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
view_models-1.5.7 lib/extensions/active_record.rb
view_models-1.5.6 lib/extensions/active_record.rb
view_models-1.5.5 lib/extensions/active_record.rb
view_models-1.5.4 lib/extensions/active_record.rb