Module: Merb::MerbWords::ApplicationHelper
- Defined in:
- app/helpers/application_helper.rb
Instance Method Summary collapse
- #merb_words_categories(options = {}) ⇒ Object
- #merb_words_orders ⇒ Object
- #merb_words_paragraph(body) ⇒ Object
- #merb_words_password_redirect ⇒ Object
- #merb_words_truncate(options = {}) ⇒ Object
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( = {}) attributes = {} attributes[:class] = 'mui_menu' attributes[:collection] = Category.all(:order => [:title.asc]) attributes[:label] = 'Categories' attributes[:multiple] = 'multiple' attributes[:selected] = [:categories].all.map {|c| c.id} attributes[:text_method] = :title attributes[:value_method] = :id select(:categories, attributes) end |
#merb_words_orders ⇒ Object
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_redirect ⇒ Object
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( = {}) characters = [:characters] || 256 title = [:title] || ' ...continued' body = [:body].gsub(/<\/?[^>]*>/, '') body = body[0, characters] + tag(:span, title, :class => 'mui_truncate') if body.size > characters merb_words_paragraph(body) end |