Class: Blogo::Post

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

Instance Method Summary collapse

Instance Method Details

#statusObject



17
18
19
# File 'app/models/blogo/post.rb', line 17

def status
  published? ? 'published' : 'draft'
end

#tag_namesArray<String>

Array of tag names. Storing arrays in tags_string we don’t need to make many-to-many join with tags table to get tag names.

Returns:

  • (Array<String>)


25
26
27
28
29
30
31
# File 'app/models/blogo/post.rb', line 25

def tag_names
  if tags_string
    tags_string.split(',').map(&:strip)
  else
    []
  end
end

#to_paramObject



34
35
36
# File 'app/models/blogo/post.rb', line 34

def to_param
  permalink
end