diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/blogs_controller.rb | 7 | ||||
-rw-r--r-- | app/controllers/entries_controller.rb | 7 | ||||
-rw-r--r-- | app/models/blog.rb | 12 | ||||
-rw-r--r-- | app/models/entry.rb | 11 | ||||
-rw-r--r-- | app/views/blogs/show.html.haml (renamed from app/views/entries/show.html.haml) | 2 | ||||
-rw-r--r-- | app/views/records/index.html.haml | 2 |
6 files changed, 19 insertions, 22 deletions
diff --git a/app/controllers/blogs_controller.rb b/app/controllers/blogs_controller.rb new file mode 100644 index 0000000..5e72601 --- /dev/null +++ b/app/controllers/blogs_controller.rb | |||
@@ -0,0 +1,7 @@ | |||
1 | class BlogsController < ApplicationController | ||
2 | |||
3 | def show | ||
4 | @blog = Blog.find_by_slug(params[:slug]) | ||
5 | end | ||
6 | |||
7 | end | ||
diff --git a/app/controllers/entries_controller.rb b/app/controllers/entries_controller.rb deleted file mode 100644 index 14d779a..0000000 --- a/app/controllers/entries_controller.rb +++ /dev/null | |||
@@ -1,7 +0,0 @@ | |||
1 | class EntriesController < ApplicationController | ||
2 | |||
3 | def show | ||
4 | @entry = Entry.find_by_slug(params[:slug]) | ||
5 | end | ||
6 | |||
7 | end | ||
diff --git a/app/models/blog.rb b/app/models/blog.rb index d2b1c27..1ace11b 100644 --- a/app/models/blog.rb +++ b/app/models/blog.rb | |||
@@ -1,4 +1,12 @@ | |||
1 | class Blog < Entry | 1 | class Blog < ApplicationRecord |
2 | has_many :records, as: :recordable, inverse_of: :recordable | ||
3 | |||
2 | validates :title, :body, presence: true | 4 | validates :title, :body, presence: true |
3 | end | 5 | validates :slug, presence: true, format: /\A[-a-z0-9]+\z/ |
4 | 6 | ||
7 | accepts_nested_attributes_for :records, allow_destroy: true | ||
8 | |||
9 | def path | ||
10 | "/says/#{slug}" | ||
11 | end | ||
12 | end | ||
diff --git a/app/models/entry.rb b/app/models/entry.rb deleted file mode 100644 index 87fd46d..0000000 --- a/app/models/entry.rb +++ /dev/null | |||
@@ -1,11 +0,0 @@ | |||
1 | class Entry < ApplicationRecord | ||
2 | has_many :records, as: :recordable, inverse_of: :recordable | ||
3 | |||
4 | validates :slug, presence: true, format: /\A[-a-z0-9]+\z/ | ||
5 | |||
6 | accepts_nested_attributes_for :records, allow_destroy: true | ||
7 | |||
8 | def path | ||
9 | "/says/#{slug}" | ||
10 | end | ||
11 | end | ||
diff --git a/app/views/entries/show.html.haml b/app/views/blogs/show.html.haml index 3a9337c..51d4aa0 100644 --- a/app/views/entries/show.html.haml +++ b/app/views/blogs/show.html.haml | |||
@@ -1,2 +1,2 @@ | |||
1 | .breadcrumb= link_to "← Back to home page", root_path | 1 | .breadcrumb= link_to "← Back to home page", root_path |
2 | = render @entry | 2 | = render @blog |
diff --git a/app/views/records/index.html.haml b/app/views/records/index.html.haml index 3850d72..200321e 100644 --- a/app/views/records/index.html.haml +++ b/app/views/records/index.html.haml | |||
@@ -4,4 +4,4 @@ | |||
4 | %span.description= link_to record.description, record.recordable.path | 4 | %span.description= link_to record.description, record.recordable.path |
5 | %ul.tags | 5 | %ul.tags |
6 | %li.record-date= record.created_at.strftime("%m.%d.%y") | 6 | %li.record-date= record.created_at.strftime("%m.%d.%y") |
7 | %li.entry-type{ class: "entry-type-#{record.recordable.type.downcase}" }= record.recordable.type | 7 | %li.entry-type{ class: "entry-type-#{record.recordable_type.downcase}" }= record.recordable_type |