Module: Merb::MerbWords::ApplicationHelper

Defined in:
app/helpers/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#merb_words_categories(options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'app/helpers/application_helper.rb', line 3

def merb_words_categories(options = {})
  attributes = {}
  attributes[:class] = 'mui_menu'
  attributes[:collection] = Category.all(:order => [:title.asc])
  attributes[:label] = 'Categories'
  attributes[:multiple] = 'multiple'
  attributes[:selected] = options[:categories].all.map {|c| c.id}
  attributes[:text_method] = :title
  attributes[:value_method] = :id
  select(:categories, attributes)
end

#merb_words_ordersObject



15
16
17
18
19
20
21
# File 'app/helpers/application_helper.rb', line 15

def merb_words_orders
  unless Order
    Order.create!(:property => 'created_at', :title => 'Date Created')
    Order.create!(:property => 'updated_at', :title => 'Date Updated')
    Order.create!(:property => 'title', :title => 'Title')
  end
end

#merb_words_paragraph(body) ⇒ Object



31
32
33
# File 'app/helpers/application_helper.rb', line 31

def merb_words_paragraph(body)
  body.gsub(/\r\n|\r|\n/, '<br/>')
end

#merb_words_password_redirectObject



23
24
25
26
27
28
29
# File 'app/helpers/application_helper.rb', line 23

def merb_words_password_redirect
  if Password
    redirect slice_url(:password_read)
  else
    redirect slice_url(:password_create)
  end
end

#merb_words_truncate(options = {}) ⇒ Object



35
36
37
38
39
40
41
# File 'app/helpers/application_helper.rb', line 35

def merb_words_truncate(options = {})
  characters = options[:characters] || 256
  title = options[:title] || ' ...continued'
  body = options[:body].gsub(/<\/?[^>]*>/, '')
  body = body[0, characters] + tag(:span, title, :class => 'mui_truncate') if body.size > characters
  merb_words_paragraph(body)
end