Module: Spud::Admin::ApplicationHelper

Defined in:
app/helpers/spud/admin/application_helper.rb

Instance Method Summary collapse

Instance Method Details



10
11
12
13
14
15
16
# File 'app/helpers/spud/admin/application_helper.rb', line 10

def link_to_add_fields(name, f, association)
  new_object = f.object.class.reflect_on_association(association).klass.new
  fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder|
    render(association.to_s.singularize + "_fields", :f => builder)
  end
  link_to_function(name, "add_fields(this, \"#{association}\", \"#{escape_javascript(fields)}\")")
end


6
7
8
# File 'app/helpers/spud/admin/application_helper.rb', line 6

def link_to_remove_fields(name, f)
 f.hidden_field(:_destroy) + link_to_function(name, "remove_fields(this)")
end

#timestamp(timedate) ⇒ Object



2
3
4
5
# File 'app/helpers/spud/admin/application_helper.rb', line 2

def timestamp(timedate)
		return "Never" if timedate.blank?
		return Time.now() - timedate > 604800 ? timedate.strftime("%B %d") + ' at ' + timedate.strftime("%I:%M %p") : time_ago_in_words(timedate) + ' ago'
end