Sha256: 2551a06628a6d4de367b657a2f34e70de1ce49971a8b2d5ddf7df7b7d308a555

Contents?: true

Size: 799 Bytes

Versions: 5

Compression:

Stored size: 799 Bytes

Contents

module Spud::Admin::ApplicationHelper
	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
    def link_to_remove_fields(name, f)
	    f.hidden_field(:_destroy) + link_to_function(name, "remove_fields(this)")
    end
  
  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
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
spud_core-0.5.1 app/helpers/spud/admin/application_helper.rb
spud_core-0.5.0 app/helpers/spud/admin/application_helper.rb
spud_core-0.4.0 app/helpers/spud/admin/application_helper.rb
spud_admin-0.2.0 app/helpers/spud/admin/application_helper.rb
spud_admin-0.1.0 app/helpers/spud/admin/application_helper.rb