Module: Contentable::Model::ClassMethods

Defined in:
lib/contentable.rb

Instance Method Summary collapse

Instance Method Details

#safe_find_by_name(name) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/contentable.rb', line 51

def safe_find_by_name(name)
  found_by_name = find_by_title(name)
  if found_by_name
    return found_by_name
  else
    content_missing = find_or_create_by_name(:name => "content_missing", :title => "Content Missing", :description => "This is the display page returned when there is no content found that matches a particular name.", :text => "This content has yet to be created.")
    # This lets the content_missing content item know what 
    # name was requested so that one can ask it for the 
    # name and create a new content item with that name.
    content_missing.missing = name
    return content_missing
  end
end