Posts - Ensure responsive (#3584)

* Fix model validations and responsiveness

* Fix model validations and responsiveness

* Update app/models/post.rb
This commit is contained in:
Daniel O'Connor
2024-01-21 16:05:14 +10:30
committed by GitHub
parent 86cc678fc7
commit 196b8078e6
3 changed files with 7 additions and 24 deletions

View File

@@ -24,8 +24,11 @@ class Post < ApplicationRecord
#
# Validations
validates :subject, presence: true, length: { maximum: 255 }
validates :body, presence: true
def author_date_subject
return unless author
# slugs are created before created_at is set
time = created_at || Time.zone.now
"#{author.login_name} #{time.strftime('%Y%m%d')} #{subject}"

View File

@@ -9,10 +9,10 @@
%h1= @author ? t('.title.author_posts', author: @author) : t('.title.default')
.row
.col-2
.col-8= will_paginate @posts
.col-md-2
.col-md-8= will_paginate @posts
.row
.col-2
.col-md-2
= render 'layouts/nav', model: Post
%hr/
%p
@@ -28,7 +28,7 @@
or
= succeed "." do
= link_to "comments RSS feed", comments_path(format: 'rss')
.col-10
.col-md-10
.row.posts
- @posts.each do |post|
.col-lg-3.col-md-6.mb-3.post

View File

@@ -571,26 +571,6 @@ ActiveRecord::Schema[7.0].define(version: 2024_01_14_045751) do
t.index ["slug"], name: "index_seeds_on_slug", unique: true
end
create_table "weather_observations", force: :cascade do |t|
t.string "source"
t.datetime "observation_at"
t.integer "solar_uv_index"
t.decimal "wind_speed_kmh"
t.decimal "wind_gust_speed_kmh"
t.string "wind_direction"
t.decimal "air_temperature_centigrade"
t.decimal "relative_humidity"
t.decimal "precipitation_probability"
t.decimal "dew_point_temperature_centigrade"
t.decimal "pressure"
t.integer "visibility_distance_metres"
t.string "weather_type"
t.bigint "owner_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["owner_id"], name: "index_weather_observations_on_owner_id"
end
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
add_foreign_key "harvests", "plantings"