Textarea Not Sending Value through Form

Viewed 2016

So I have a form in my view..

  form_for(ActivityComment.new, remote: true, url: "/activity_comments/create", class: "col-md-6") do |f|
    f.hidden_field :klass_name, value: activity.klass
    f.hidden_field :klass_id, value: activity.id
    f.text_area :comment, class: "form-control"
    f.submit "Submit", class: "btn btn-success"
  end

The html is printed out as...

<form accept-charset="UTF-8" action="/activity_comments/create" class="new_activity_comment" data-remote="true" id="new_activity_comment" method="post">
  <div style="margin:0;padding:0;display:inline">
    <input name="utf8" type="hidden" value="✓">
  </div>
  <input id="activity_comment_klass_name" name="activity_comment[klass_name]" type="hidden" value="Friend">
  <input id="activity_comment_klass_id" name="activity_comment[klass_id]" type="hidden" value="3">
  <textarea class="form-control" id="activity_comment_comment" name="activity_comment[comment]"></textarea>
  <input class="btn btn-success" name="commit" type="submit" value="Submit">
</form>

However the params I receive in the controller is...

Parameters: {"utf8"=>"✓", "activity_comment"=>{"klass_name"=>"Friend", "klass_id"=>"3", "comment"=>""}, "commit"=>"Submit"}

The activity comment model

# == Schema Information
#
# Table name: activity_comments
#
#  id         :integer          not null, primary key
#  user_id    :integer
#  klass_name :string(255)
#  klass_id   :integer
#  comment    :text
#  created_at :datetime
#  updated_at :datetime

class ActivityComment < ActiveRecord::Base
  belongs_to :user
end

The comment attribute is returning empty no matter what. I'm to believe that it has something to do with the textarea as using a plain input field made it work. What's wrong and how do I fix it?

3 Answers
Related