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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:29:49+00:00 2026-05-23T18:29:49+00:00

So, I’ve got this action in order to save a model: def create logger.debug(params[:user_id])

  • 0

So, I’ve got this action in order to save a model:

def create
    logger.debug(params[:user_id])
    group_id = params['approver']['group_id']
    @approver = Approver.new(params[:approver])
    @approver.user_id = params[:user_id]

    respond_to do |format|
      if @approver.save
        logger.warn("Approver saved!")
        flash[:notice] = "New approver has been added!"
        format.html { redirect_to(group_path(group_id)) }
      else
        flash[:notice] = "Sorry .. had issues adding the approvers!"
        format.html { redirect_to(group_path(group_id)) }
      end
    end
  end

Parameters being passed in are:

Parameters: {"commit"=>"Submit", "authenticity_token"=>"C35lovRRjJzekruZiwTZjaMs4KgwiEJnXn10b0nD+0w=", "utf8"=>"✓", "user_id"=>["18"], "approver"=>{"group_id"=>"13"}}

And looking at my logs, the debug message in the action prints ’13’ as the correct value. However, the value being inserted into the database is always ‘1’ and here’s the snippet from the logs:

INSERT INTO `approvers` (`user_id`, `updated_at`, `created_at`, `group_id`) VALUES (1, '2011-07-13 04:58:51', '2011-07-13 04:58:51', 13)

To further complicate matters, in order to debug, if I change line 5 of the action to:

@approver.user_id = 19

it all works fine.

Can anyone explain what I’m doing wrong?

  • 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-23T18:29:50+00:00Added an answer on May 23, 2026 at 6:29 pm

    The group_id isn’t your problem, that is going through fine. Your problem is this:

    "user_id"=>["18"]
    

    So params[:user_id] is actually an array but you’re treating it like an ID. Then, someone inside Rails is converting that array to 1. When you say this:

    @approver.user_id = 19
    

    Everything works because you’re assigning a Fixnum to user_id and that’s what user_id expects.

    You need to figure out why you’re getting an array user_id and then fix that. Or, figure out what you should do with an array, maybe @approver.user_id = params[:user_id][0] makes sense, maybe not.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace
this is what i have right now Drawing an RSS feed into the php,
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
i got an object with contents of html markup in it, for example: string
Does anyone know how can I replace this 2 symbol below from the string

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.