Module: ViewHelpers

Included in:
PixelearthBase::ApplicationHelper
Defined in:
app/helpers/view_helpers.rb

Overview

these helper are meant to not be needed as controller methods. Use ControllerHelpers instead the render :partial in 3.1 doesn’t work the same when coming from a helper module as when defined with helper_method.

Instance Method Summary collapse

Instance Method Details

#admin_buttonsObject



53
54
55
# File 'app/helpers/view_helpers.rb', line 53

def admin_buttons
  render :partial => 'pixelearth_base/admin/admin_buttons'
end

#clearObject



44
45
46
# File 'app/helpers/view_helpers.rb', line 44

def clear
  "<br style='clear:both'/>".html_safe
end

#date(date, format = :default) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'app/helpers/view_helpers.rb', line 34

def date(date, format=:default)
  #ref: http://snippets.dzone.com/posts/show/2255
  formats = {
    :default   => "%b %d, %Y",
    :numbers   => "%m-%d-%y",
    :date_time => "%b %d, %Y %I:%M %p",
    :just_time => "%I:%M %p",
  }
  date.strftime(formats[format])
end

#form_errors_helperObject

———– SCAFFOLD ————–



50
51
52
# File 'app/helpers/view_helpers.rb', line 50

def form_errors_helper
  render :partial => 'pixelearth_base/admin/form_errors'
end


59
60
61
# File 'app/helpers/view_helpers.rb', line 59

def link_to_destroy
  raw link_to('destroy', @resource, :confirm => 'Are you sure you want to remove this?', :method => :delete, :title => 'remove permanently')
end

#on_if_controller(c) ⇒ Object



9
10
11
12
13
# File 'app/helpers/view_helpers.rb', line 9

def on_if_controller(c)
  if params[:controller] == c.to_s 
    'on'
  end
end

#on_if_current(path) ⇒ Object



4
5
6
7
8
# File 'app/helpers/view_helpers.rb', line 4

def on_if_current(path)
  if path == request.fullpath
    'on'
  end
end

#paginate(collection) ⇒ Object



62
63
64
# File 'app/helpers/view_helpers.rb', line 62

def paginate(collection)
  render :partial => 'pixelearth_base/pagination.html.haml', :locals => { :collection => collection }
end

#row_toggleObject



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

def row_toggle
  cycle('a','b')
end

#short_text(st, len = 100) ⇒ Object



28
29
30
# File 'app/helpers/view_helpers.rb', line 28

def short_text(st, len=100)
  raw truncate( strip_tags( raw(st)), :length=>len)
end

#show_edit_destroy(resource) ⇒ Object



56
57
58
# File 'app/helpers/view_helpers.rb', line 56

def show_edit_destroy(resource)
  render(:partial => 'pixelearth_base/admin/show_edit_destroy', :locals => {:resource => resource})
end


25
26
27
# File 'app/helpers/view_helpers.rb', line 25

def titled_link_to(resource)
  link_to(resource.name.titleize, send("#{resource.class.to_s.underscore}_path", resource), :title =>  "View Full #{resource.class.to_s.titleize} Details for #{h resource.name.titleize}")
end

#tr(d) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'app/helpers/view_helpers.rb', line 14

def tr(d)
# Quick array to table row.
# Takes an array and creates a table row (tr) with each element of the array
# occupying one column (td).
  o = "<tr>\n"
  d.each do |x|
    o << "\t<td>#{x}</td>\n"
  end
  o << "</tr>\n"
  o
end