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 9156411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:46:16+00:00 2026-06-17T12:46:16+00:00

Target : save comment for idea model. Form: <%= form_for([@idea, IdeaComment.new], :validate => true)

  • 0

Target: save comment for idea model.

Form:

<%= form_for([@idea, IdeaComment.new], :validate => true) do |f| %>
        <div class="control-group">
            <div class="controls">
                <%= f.text_area :text, :placeholder => 'some text', :rows => 5 %>
                <%= validate_errors(IdeaComment.new) %>
            </div>
        </div>
        <%= f.button 'Comment', :class => 'button grad-green', :type => 'submit' %>
    <% end %>

Controller:

 @idea_comment = IdeaComment.new(params[:idea_comment])
 ...

But if we take a look for params hash:
enter image description here

How to pass idea_id to “idea_comment”?

  • 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-06-17T12:46:17+00:00Added an answer on June 17, 2026 at 12:46 pm

    Client-side validation is conflicting with resource-oriented forms. Use regular server-side validation instead.

    Explanation:

    Resource-oriented forms post to a path based on nested resources:

    form_for([@idea, IdeaComment.new]) # => POST '/ideas/[:idea_id]/idea_comments'
    

    Rails extracts :idea_id from the request path and passes it in as a parameter. In the create action, the association is set by direct assignment prior to saving:

    # controllers/idea_comments_controller.rb
    def create
      @idea_comment = IdeaComment.new(params[:idea_comment])
      @idea_comment.idea_id = params[:idea_id]
      # ...
      @idea_comment.save
    end
    

    The problem with client-side validation is that it will fail and block form submission until @idea_comment.idea_id is assigned, which doesn’t happen until after the form is submitted.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(The target browser is IE8) I have a div that contains a list of
my target slideToggle() div needs to be display:inline-block instead of display:block when it's open.
i want to target closest div from my anchor tag. so in order do
I'm having trouble creating a new model row in the database using ActiveRecord in
i try to save my form with CKEditor and add autosave function mean all
I'm doing Project Euler #22: Using names.txt (right click and 'Save Link/Target As...'), a
I'm using this two plug-ins jquery.validate and jquery.form separately, but I would like to
I've met a scenario: save or update some data in a target table by
I have public class Entity On which works class: public class Table<Target extends Entity>
I want to target specific iframes using a class attribute in order to set

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.