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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:39:32+00:00 2026-06-14T00:39:32+00:00

I’m trying to create a simple User & Address Model. I’ve created a nested

  • 0

I’m trying to create a simple User & Address Model.

I’ve created a nested form that has an address model nested into the User model. My User Model has the devise attributes etc.

It all works fine, except that there’s a strange behaviour happening when the user is created.

If you read below, you’ll notice the “user_id” which is the address of the owning user is populated when the record is first committed. But then immediately afterward, something that looks like it’s in Devise core, is resetting the user_id to null.

Does anyone know what would be causing this?

Started POST “/users” for 127.0.0.1 at 2012-11-03 22:45:20 +1100
Processing by Member::UsersController#create as HTML Parameters:
{“utf8″=>”✓”,
“authenticity_token”=>”Pr8lSEJalWwosuaLPOrYqQ+sOkFCyoNujaUybxpZDAg=”,
“user”=>{“address_attributes”=>{“first_name”=>”HOlley”,
“last_name”=>”Hou”}, “email”=>”HollyHou@hisense.com.au”,
“password”=>”[FILTERED]”, “password_confirmation”=>”[FILTERED]”}}
Creating a new user (0.1ms) BEGIN (0.1ms) COMMIT (0.0ms)
BEGIN Member::User Exists (0.3ms) SELECT 1 AS one FROM
member_users WHERE member_users.email = BINARY
‘hollyhou@hisense.com.au’ LIMIT 1 SQL (0.2ms) INSERT INTO
member_users (created_at, current_sign_in_at,
current_sign_in_ip, email, encrypted_password,
last_sign_in_at, last_sign_in_ip, remember_created_at,
reset_password_sent_at, reset_password_token, sign_in_count,
updated_at) VALUES (‘2012-11-03 11:45:20’, NULL, NULL,
‘hollyhou@hisense.com.au’,
‘$2a$10$1JvC/sO85L2esNp8xA9qseTc78.rtOyF3zSBi/fOTiWJRt9.zgYha’, NULL,
NULL, NULL, NULL, NULL, 0, ‘2012-11-03 11:45:20’) SQL (0.2ms)
INSERT INTO member_addresses (address3, address_1, address_2,
address_type, business_name, city, country, created_at,
first_name, geo_late, geo_long, is_primary, last_name,
middle_name, phone1, phone1_type, phone2, phone2_type,
postcode, primary_email, secondary_email, state, status,
suburb, title, updated_at, user_id) VALUES (NULL, NULL, NULL,
NULL, NULL, NULL, NULL, ‘2012-11-03 11:45:20’, ‘HOlley’, NULL, NULL,
NULL, ‘Hou’, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, ‘2012-11-03 11:45:20’, 5) (1.3ms) COMMIT
(0.1ms) BEGIN (0.2ms) UPDATE member_users SET last_sign_in_at
= ‘2012-11-03 11:45:20’, current_sign_in_at = ‘2012-11-03 11:45:20’, last_sign_in_ip = ‘127.0.0.1’, current_sign_in_ip = ‘127.0.0.1’,
sign_in_count = 1, updated_at = ‘2012-11-03 11:45:20’ WHERE
member_users.id = 5 (0.2ms) COMMIT (0.1ms) BEGIN
(0.2ms) UPDATE member_addresses SET user_id = NULL, updated_at
= ‘2012-11-03 11:45:20’ WHERE member_addresses.id = 5 (0.2ms) COMMIT

The controller is a custom controller because I eventually (once I get this working), need to be able to redirect to 2 different places after registration depending where the customer logged in from (checkout or header in this case).

class Member::UsersController < Devise::RegistrationsController
  def create
    super
  end

  def new
    super
  end

  def edit
    Rails.logger.debug { "Editing the user" }
    super
  end

  def show
    Rails.logger.debug { "Showing the user controller" }
  end
end

and from routes.rb

  devise_for :users, :class_name => "Member::User", :controllers => {:registrations => 'member/users', :sessions => 'member/sessions'}
  • 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-14T00:39:33+00:00Added an answer on June 14, 2026 at 12:39 am

    I finally figured this out. It was actually related to an answer I got from a previous question regarding nested form.

    In this code below, previously in the nested address field, I was always calling build_address and because address is one to one relationship when the form was refreshing it was creating a new address. Now I think it should be ok, I haven’t tested it, but at least the address nullification problem is resolved.

    resource_name,:url =>
    registration_path(resource_name), :html => {:class =>
    ‘form-horizontal’ }) do |f| %>
    Mandatory fields marked *

    “alert alert-error”, :id => “flash_error”) if flash[:error] %>
    “flash_notice”) if flash[:notice] %>
    “alert alert-error”, :id => “flash_alert”) if flash[:alert] %>

    {:class => “input-xlarge”} %>
    {:class => “input-xlarge”} %>

            <%= f.input :email, :input_html => {:class => "input-xlarge"} %>
            <%= f.input :password, :required => true, :input_html => {:class => "input-xlarge"}   %>
            <%= f.input :password_confirmation, :required => true, :input_html => {:class => "input-xlarge"} %>
            <div class="form-actions">
              <%= f.button :submit, "Register", :class => "btn btn-success btn-large" %>
            </div>
        <% end %>
    
    • 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 &#8217; in it. SimpleXML turns this
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to create an if statement in PHP that prevents a single post
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am doing a simple coin flipping experiment for class that involves flipping a
I have a French site that I want to parse, but am running into
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all

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.