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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:42:47+00:00 2026-06-14T12:42:47+00:00

I have implemented nested attributes using railscasts and I am using devise in application.

  • 0

I have implemented nested attributes using railscasts and I am using devise in application. Here is the simple structure.

I have two model ie Group and Invite.

Group Model has

accepts_nested_attributes_for :invites, :reject_if => lambda { |a| a[:email].blank? }, :allow_destroy => true

and it works perfectly fine.
here is the hash of the parameters.

 Parameters: {"utf8"=>"✓", "authenticity_token"=>"uI0HmJrIE9Qh3pZW2qIJymeON/yjbFSgcH8bRx/x5Oo=", "group"=>{"name"=>"Test Group", "description"=>"", "invites_attributes"=>{"0"=>{"name"=>"Test User", "email"=>"test@example.com", "_destroy"=>"false"}}}, "commit"=>"Create Group"}

Now the problem is I want to store invitee user_id in invites table, But I can access current_user in invite model. So how can I modify the hash in order to save current_user id in invite model.

Basically things will be easy if my hash parameters is:

 Parameters: {"utf8"=>"✓", "authenticity_token"=>"uI0HmJrIE9Qh3pZW2qIJymeON/yjbFSgcH8bRx/x5Oo=", "group"=>{"name"=>"Test Group", "description"=>"", "invites_attributes"=>{"0"=>{"name"=>"Test User", "email"=>"test@example.com", "_destroy"=>"false", :invited_by => "1" }}}, "commit"=>"Create Group"}

How can I modify hash at controller end? or is there is better way to achieve this.

  • 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-14T12:42:50+00:00Added an answer on June 14, 2026 at 12:42 pm

    Maybe you could try using hidden_field.

    So, you may write something like this (based on the Railscasts):

    # /app/views/surveys/_question_fields.html.erb
    <div class="fields">
      <p>
        <%= f.hidden_field :user_id, :value => "1" %>
        <%= f.label :content, "Question" %>
        <%= link_to_remove_fields "remove", f %><br />
        <%= f.text_area :content, :rows => 3 %><br />
      </p>
      <% f.fields_for :answers do |builder| %>
        <%= render 'answer_fields', :f => builder %>
      <% end %>
      <p><%= link_to_add_fields "Add Answer", f, :answers %></p>
    </div>
    

    From APIdock:

    One important thing to remember is that this is NOT hidden in the
    source code and can be modified by an evil user so all input in a
    hidden field should be considered as untrustworthy and checked just
    like a visible field.

    Ref:

    • http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-hidden_field
    • http://apidock.com/rails/ActionView/Helpers/FormHelper/hidden_field
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a menu implemented using a set of nested accordions, 1 and 2
I have a Subject Model and a Lesson Model. I implemented a nested model
I have implemented clean URLs using the following in my .htaccess RewriteEngine on RewriteCond
I have implemented a very basic sign up using email address+name, although I would
I have implemented a simple entity ejb with a @version annotation. I expect that
I have implemented a nested class in Java, and I need to call the
I have a C++ state machine implemented using the State design pattern. Each state
What my application Does: I have implemented facebook login for my website. And i
I have a model Post which belongs_to one Section . There are two different
I have just re-implemented an ASP.NET web application that uses NHibernate to use 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.