Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7508257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:38:55+00:00 2026-05-29T22:38:55+00:00

I have the following within a form_for: = form_for @activity do |f| .field =

  • 0

I have the following within a form_for:

  = form_for @activity do |f|
    .field
      = label :comment, :comment
      = text_area :comment, :comment, :rows => 4

I am not calling f.label or f.text_area because comment is a separate model and I am saving it separately. The above code works fine, but when the validation fails on @activity, then the comment gets wiped out. I would like for the comment field to repopulate when the @activity validation fails, so I tried the following:

  = form_for @activity do |f|
    .field
      = label :comment, :comment
      = text_area :comment, :comment, :value => @comment, :rows => 4

With this line in the controller action:

@comment = Comment.new(params[:comment][:comment])

With this, however, I get the following error:

undefined method `stringify_keys' for "hello":String

It is failing on the @comment assignment in the controller which I show above.

What is going on here?

The params after the error contain the following:

 "comment"=>{"comment"=>"hello"}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T22:38:55+00:00Added an answer on May 29, 2026 at 10:38 pm

    The problem is that Comment#new expects a Hash whose keys correspond to Comment’s attributes but you’re giving it params[:comment][:comment], whose value is a string (in this case, "hello"). I suspect that this is what you want instead:

    @comment = Comment.new params[:comment]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following view within an app called 'manager': class AddObj(CreateView): model =
I have the following within an XHTML document: <script type=text/javascript id=JSBALLOONS> function() { this.init
I have the following code within a stored procedure. WHERE WPP.ACCEPTED = 1 AND
I have the following user control that is embedded within another user control. <UserControl.Resources>
I have the following function which works very well within a $(document).ready(function(){ $('.threadWrapper >
I have the following Macro I want to call from within an AutoHotkey script
I have the following HTML to center images and links within a layer: edit:
In the following code, I have verified that connecting to a URL from within
Within a web form I have the following jQuery setup to call a method
On a page I have a google search-field and a separate form for a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.