Module: Ramaze::Helper::Tags

Defined in:
lib/cortex_reaver/helper/tags.rb

Instance Method Summary collapse

Instance Method Details

#tagged(tags) ⇒ Object

Finds models with a given tag.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/cortex_reaver/helper/tags.rb', line 7

def tagged(tags)
  tags = tags.split(',').map! do |tag|
    CortexReaver::Tag.get(tag.gsub(/[^-_\w]+/, '').strip)
  end

  @title = "#{model_class.to_s.demodulize.pluralize.titleize}: #{tags.join(', ')}"
  @models = model_class.tagged_with(tags)
  set_plural_model_var @models

  if user.can_create? model_class.new
    workflow "New #{model_class.to_s.demodulize}", rs(:new)
  end

  render_view(:list)
end