Class Her::Model::Associations::Association
In: lib/her/model/associations/association.rb
Parent: Object

Methods

Attributes

params  [RW]  @private

Public Class methods

Public Instance methods

all(params = {})

Alias for where

Fetches the data specified by id

@example

  class User
    include Her::Model
    has_many :comments
  end

  user = User.find(1)
  user.comments.find(3) # Fetched via GET "/users/1/comments/3

Refetches the association and puts the proxy back in its initial state, which is unloaded. Cached associations are cleared.

@example

  class User
    include Her::Model
    has_many :comments
  end

  class Comment
    include Her::Model
  end

  user = User.find(1)
  user.comments = [#<Comment(comments/2) id=2 body="Hello!">]
  user.comments.first.id = "Oops"
  user.comments.reload # => [#<Comment(comments/2) id=2 body="Hello!">]
  # Fetched again via GET "/users/1/comments"

@private

Add query parameters to the HTTP request performed to fetch the data

@example

  class User
    include Her::Model
    has_many :comments
  end

  user = User.find(1)
  user.comments.where(:approved => 1) # Fetched via GET "/users/1/comments?approved=1

[Validate]