add create new post button on sidebar when user is signed in

This commit is contained in:
acon 2025-05-02 18:11:25 -04:00
parent f7c2c317bc
commit a1f7ccc3af
2 changed files with 11 additions and 1 deletions

View file

@ -1,6 +1,13 @@
<div class="w-72 border-r-4 border-r-[#2E2A54] text-white p-5 h-screen fixed">
<%= image_tag "logo.png", class: "w-full mb-8" %>
<% if current_user %>
<div class="text-center grid grid-cols-1 gap-2 text-xl mb-12">
<%= link_to "+ Create new post", new_post_path, class: "bg-[#62D5C3] p-2 rounded-4xl transition duration-100 block text-[#252036] font-bold" %>
</div>
<% end %>
<div class="text-center grid grid-cols-1 gap-2 text-xl font-dystopian">
<%= link_to "Main", posts_path, class: "#{current_page?(posts_path) ? 'bg-[#564CAD]' : 'hover:bg-[#564CAD]'} bg-[#2E2A54] p-2 rounded transition duration-100 block" %>
<%= link_to "User", root_path, class: "#{current_page?(root_path) ? 'bg-[#564CAD]' : 'hover:bg-[#564CAD]'} bg-[#2E2A54] p-2 rounded transition duration-100 block" %>

5
site/db/schema.rb generated
View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[8.0].define(version: 2025_04_29_161341) do
ActiveRecord::Schema[8.0].define(version: 2025_04_29_211703) do
create_table "action_text_rich_texts", force: :cascade do |t|
t.string "name", null: false
t.text "body"
@ -54,6 +54,8 @@ ActiveRecord::Schema[8.0].define(version: 2025_04_29_161341) do
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "hours"
t.integer "user_id"
t.index ["user_id"], name: "index_posts_on_user_id"
end
create_table "users", force: :cascade do |t|
@ -66,4 +68,5 @@ ActiveRecord::Schema[8.0].define(version: 2025_04_29_161341) do
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 "posts", "users"
end