Class: Blogelator::Post

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/blogelator/post.rb

Instance Method Summary collapse

Instance Method Details

#to_paramString

Uses the slug as the :id parameter in URLs

Returns:

  • (String)


38
39
40
# File 'app/models/blogelator/post.rb', line 38

def to_param
  slug
end

#url(request = nil) ⇒ String

The URL for the blog post.

Returns:

  • (String)


44
45
46
47
48
49
50
51
52
# File 'app/models/blogelator/post.rb', line 44

def url(request = nil)
  @url ||= begin
    if request.try(:ssl?)
      "https://#{ENV.fetch('HOST')}/blog/#{slug}"
    else
      "http://#{ENV.fetch('HOST')}/blog/#{slug}"
    end
  end
end