rails content for head

# 1. Create a new Rails migration to add a 'content' column to the 'heads' table
rails generate migration AddContentToHeads content:text

# 2. Run the migration to apply the changes to the database
rails db:migrate

# 3. Update the 'Head' model to include the 'content' attribute
# app/models/head.rb
class Head < ApplicationRecord
  validates :content, presence: true
end

# 4. Update the strong parameters in the 'HeadsController' to permit the 'content' attribute
# app/controllers/heads_controller.rb
def head_params
  params.require(:head).permit(:content)
end

# 5. Modify the 'new' and 'edit' views to include a form field for the 'content' attribute
# app/views/heads/new.html.erb
# app/views/heads/edit.html.erb
<%= form_with(model: head, local: true) do |form| %>
  <!-- existing form fields -->
  <div class="field">
    <%= form.label :content %>
    <%= form.text_area :content, rows: 3 %>
  </div>
  <!-- existing form fields -->
<% end %>

# 6. Update the 'create' and 'update' actions in the 'HeadsController' to include the 'content' parameter
# app/controllers/heads_controller.rb
def create
  @head = Head.new(head_params)
  # existing code
end

def update
  # existing code
  if @head.update(head_params)
    # existing code
  else
    # existing code
  end
end

# 7. Display the 'content' attribute in the 'show' view
# app/views/heads/show.html.erb
<p>
  <strong>Content:</strong>
  <%= @head.content %>
</p>