Sha256: c572600a6c3f4a231d634318dca3cf1616d8faf52084b7682d6273f76a9ce859

Contents?: true

Size: 802 Bytes

Versions: 8

Compression:

Stored size: 802 Bytes

Contents

module CreatedByHelper
  def text_created_by(model, action = "create", mode = "short")
    begin
      if action.include?("update")
        id = model.updated_by
        time = model.updated_at
      else
        id = model.created_by
        time = model.created_at
      end
      user = <%= user.camelize %>.<%= options.friendly? ? 'friendly.' : '' %>find(id)
      name = user.name
      email = user.email
    rescue
      return ""
    end
    case mode
      when "name"
        name
      when "email"
        email
      when "user"
        mail_to(email, name)
      when "long"
        "#{mail_to(email, name)} (#{l(time)})"
      when "link"
        "#{link_to(name, user)} (#{l(time.to_date)})"
      else          
        "#{mail_to(email, name)} (#{l(time.to_date)})"
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
bootswatch_rails-3.3.7.8 lib/generators/bootswatch_rails/created_by/templates/created_by_helper.rb
bootswatch_rails-3.3.7.7 lib/generators/bootswatch_rails/created_by/templates/created_by_helper.rb
bootswatch_rails-3.3.7.6 lib/generators/bootswatch_rails/created_by/templates/created_by_helper.rb
bootswatch_rails-3.3.7.5 lib/generators/bootswatch_rails/created_by/templates/created_by_helper.rb
bootswatch_rails-3.3.7.4 lib/generators/bootswatch_rails/created_by/templates/created_by_helper.rb
bootswatch_rails-3.3.7.3 lib/generators/bootswatch_rails/created_by/templates/created_by_helper.rb
bootswatch_rails-3.3.7.2 lib/generators/bootswatch_rails/created_by/templates/created_by_helper.rb
bootswatch_rails-3.3.7.1 lib/generators/bootswatch_rails/created_by/templates/created_by_helper.rb