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

  • Home
  • SEARCH
  • 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 8024659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:55:24+00:00 2026-06-04T22:55:24+00:00

My configuration: Devise Devise Views expanded out Using a separate Registrations controller (moved the

  • 0

My configuration:

Devise

Devise Views expanded out

Using a separate Registrations controller (moved the files from views/devise/registrations to views/registrations)

I have a hidden field in the new registration form that is supposed to be filled after the form is submitted, but the value is not being saved to the database.

Here’s what I have:

In routes.rb:

devise_for :users, :controllers => { :registrations => 'registrations' }, :path => '', :path_names => { :sign_in => "login", :sign_up => "request_invite" }

In views/regiistrations/new, I have company_id defined as a hidden field

In models/user.rb, I have:

attr_accessible: company_id

In registrations_controller.rb, I have:

class RegistrationsController < Devise::RegistrationsController
  ........
def create
  @user = User.new(params[:user])
  company_id = params[:user][:company] + "_" + params[:user][:ssid]
  params[:user][:company_id] = company_id.downcase

  respond_to do |format|
    if @user.save
      flash[:notice] = "New user added"
      format.html { redirect_to root_url }
      format.json { render json: @user, status: :created, location: @user }
    else
      format.html { render action: "new" }
      format.json { render json: @user.errors, status: :unprocessable_entity }
    end
  end
end 
.....

The contents of the form are saved to the DB, but not company_id. I verified that company_id is actually being created, and is actually passed on as part of user params. Did the save to DB occur somewhere before I computed company_id? I saw a bunch of StackOverflow Q/A on similar topics, but nothing worked or fit what I am trying to do. Newbie here, so perhaps I am not familiar with all the things to look for, as I imagine that this something people do on regular basis.

UPDATE:

To make sure the Q/A is complete, following is the correct code:

class RegistrationsController < Devise::RegistrationsController
........
  def create
    @user = User.new(params[:user])
    company_id = params[:user][:company] + "_" + params[:user][:ssid]
    @user.company_id = company_id.downcase

    respond_to do |format|
      if @user.save
        flash[:notice] = "New user added"
        format.html { redirect_to root_url }
        format.json { render json: @user, status: :created, location: @user }
      else
        format.html { render action: "new" }
        format.json { render json: @user.errors, status: :unprocessable_entity }
      end
    end
  end 
  .....
  • 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-04T22:55:26+00:00Added an answer on June 4, 2026 at 10:55 pm

    Change this line: params[:user][:company_id] = company_id.downcase

    To this: @user.company_id = company_id.downcase

    Changing the params does nothing, as you have already created the object using the previous hash values.

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

Sidebar

Related Questions

I created the /views/user/ folder using rails g devise:views but devise is still using
using devise 2.1.0 I had to override the devise registration controller. In the process
I have the following requirement: In C#2.0, Given a device configuration in xml format
Configuration File Path : /etc/php.ini Additional .ini files under /etc/php.d : curl.ini, fileinfo.ini,gd.ini,json.ini, mysql.ini,
Proxy configuration of a machine can be easily fetched using def check_proxy(): import urllib2
I have log4j jdbcappender configuration as follows: <appender name=jdbcAppender class=bean.CustomJdbcAppender> <param name=jndiDataSource value=myDS/> <layout
I see in the config/initializers/devise.rb, there is a configuration called config.stretches. # ==> Configuration
I'm using Devise and Netzke gems. My rails version is 3.1.1 I want to
Starting with an app already in development, I have carried out the instructions in
I have created a simple Xcode 4.2 project with a empty view controller. I

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.