Module Waves::Helpers::Model
In: lib/helpers/model.rb

Model helpers allow you to directly access a model from within a view. This is useful when creating things like select boxes that need data from anther model. For example, a Markaby select box for authors might look like:

  select do
    all(:user).each do |user|
      option user.full_name, :value => user.id
    end
  end

You could also use these within a view class to keep model-based logic out of the templates themselves. For example, in the view class you might define a method called authors that returns an array of name / id pairs. This could then be called from the template instead of the model helper.

Methods

all   find   model  

Public Instance methods

Just like model.all. Returns all the instances of that model.

[Source]

    # File lib/helpers/model.rb, line 26
26:       def all( model )
27:         model( model ).all
28:       end

Finds a specific instance using the name field

[Source]

    # File lib/helpers/model.rb, line 31
31:       def find( model, name )
32:         model( model )[name ] rescue nil
33:       end

[Source]

    # File lib/helpers/model.rb, line 21
21:       def model( name )
22:         Waves.main::Models[ name ][ domain ]
23:       end

[Validate]