From: Aidan Cornelius-Bell Date: Mon, 16 Sep 2024 08:34:17 +0000 (+0930) Subject: fixed duplicate fields in the post form X-Git-Url: https://gitweb.mndrdr.org/?a=commitdiff_plain;h=1b2fca19db27778d19a383fb9d515a0b7d2d664b;p=arelpe.git fixed duplicate fields in the post form --- diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 4b39f11..e9e295e 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -24,11 +24,18 @@ class PostsController < ApplicationController def create @post = Post.new(post_params) @post.slug = @post.title.parameterize if @post.title.present? - + + puts "Raw params: #{params.inspect}" + puts "Post params: #{post_params.inspect}" + puts "Post content: #{@post.content.inspect}" + puts "Post type: #{@post.post_type}" + if @post.save redirect_to @post, notice: "Post was successfully created." else - render :new, status: :unprocessable_entity + puts "Post errors: #{@post.errors.full_messages}" + puts "Post object: #{@post.attributes}" + render :new, status: :unprocessable_entity end end diff --git a/app/views/.DS_Store b/app/views/.DS_Store index 21c52c5..90d4b9e 100644 Binary files a/app/views/.DS_Store and b/app/views/.DS_Store differ diff --git a/app/views/posts/_form.html.erb b/app/views/posts/_form.html.erb index dc31e1b..3595cf3 100644 --- a/app/views/posts/_form.html.erb +++ b/app/views/posts/_form.html.erb @@ -1,4 +1,4 @@ -<%= form_with(model: post, local: true) do |form| %> +<%= form_with(model: post, local: true, data: { debug: true }) do |form| %> <% if post.errors.any? %>

<%= pluralize(post.errors.count, "error") %> prohibited this post from being saved:

@@ -25,9 +25,9 @@ <%= form.datetime_local_field :published_at %>
-
+
<%= form.label :content %> - <%= form.text_area :content, class: 'markdown-editor', rows: 10 %> + <%= form.text_area :content, id: 'post_content' %>
@@ -40,17 +40,14 @@ <%= form.url_field :url, onblur: 'fetchTitle()' %>
- -
<%= form.submit(class: "button") %>
<% end %> \ No newline at end of file