#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. module ViewHelpers def on_if_current(path) if path == request.fullpath 'on' end end def on_if_controller(c) if params[:controller] == c.to_s 'on' end end 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 = "\n" d.each do |x| o << "\t#{x}\n" end o << "\n" o end 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 def short_text(st, len=100) raw truncate( strip_tags( raw(st)), :length=>len) end def row_toggle cycle('a','b') end 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 def clear "
".html_safe end # ----------- SCAFFOLD -------------- def form_errors_helper render :partial => 'pixelearth_base/admin/form_errors' end def admin_buttons render :partial => 'pixelearth_base/admin/admin_buttons' end def show_edit_destroy(resource) render(:partial => 'pixelearth_base/admin/show_edit_destroy', :locals => {:resource => resource}) end def link_to_destroy raw link_to('destroy', @resource, :confirm => 'Are you sure you want to remove this?', :method => :delete, :title => 'remove permanently') end def paginate(collection) render :partial => 'pixelearth_base/pagination.html.haml', :locals => { :collection => collection } end end