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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:42:22+00:00 2026-05-29T10:42:22+00:00

I’ve noticed that created resouce attributes are all blank after executing build_resource at Devise::RegistrationsController

  • 0

I’ve noticed that created resouce attributes are all blank after executing build_resource at Devise::RegistrationsController create function

here is the params object sent:

 "student"=>{"first_name"=>"George",
 "last_name"=>"Michle",
 "company_name"=>"Meri",
 "work_title"=>"Architect",
 "address"=>"Moon",
 "postal_code"=>"23410",
 "work_phone"=>"",
 "home_phone"=>"",
 "mobile_phone"=>"",
 "fax"=>"",
 "email"=>"gion@gmail.com",
 "password"=>"[FILTERED]",
 "password_confirmation"=>"[FILTERED]",
 "country_id"=>"2",
 "state_province_id"=>"2"}

Here is the resulted resource attributes:

[["address", ""], ["city", nil], ["company_name", ""], ["country_id", 1], ["created_at", Wed, 08 Feb 2012 04:52:35 UTC +00:00], ["current_sign_in_at", nil], ["current_sign_in_ip", nil], ["email", ""], ["encrypted_password", ""], ["fax", ""], ["first_name", ""], ["home_phone", ""], ["last_name", ""], ["last_sign_in_at", nil],  ["last_sign_in_ip", nil], ["license_number", nil], ["mobile_phone", ""], ["postal_code", ""], ["remember_created_at", nil], ["reset_password_sent_at", nil], ["reset_password_token", nil], ["sign_in_count", 0], ["state_province_id", nil], ["updated_at", Wed, 08 Feb 2012 04:52:35 UTC +00:00], ["username", nil], ["work_phone", ""], ["work_title", ""]]

So, why build_resource could not populate the params ? Where to look to solve this problem ?
Any help will be more than appreciated.

EDIT:

Here is the student model:

class Student < ActiveRecord::Base

  has_many :students_courseses
  has_many :courses , :through => :students_courseses



  # Include default devise modules. Others available are:
  # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable, :timeoutable

  belongs_to :country
  #validates :weburl, :url => {:allow_blank => true}, :length => { :maximum => 50 }

  validates_length_of :work_phone, :is => 10, :message => 'must be 10 digits, excluding special characters such as spaces and dashes. No extension or country code allowed.', :if => Proc.new{|o| !o.work_phone.blank?}
  validates_length_of :home_phone, :is => 10, :message => 'must be 10 digits, excluding special characters such as spaces and dashes. No extension or country code allowed.', :if => Proc.new{|o| !o.home_phone.blank?}
  validates_length_of :mobile_phone, :is => 10, :message => 'must be 10 digits, excluding special characters such as spaces and dashes. No extension or country code allowed.', :if => Proc.new{|o| !o.mobile_phone.blank?}
  validates_length_of :fax, :is => 10, :message => 'must be 10 digits, excluding special characters such as spaces and dashes. No extension or country code allowed.', :if => Proc.new{|o| !o.fax.blank?}

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :password, :password_confirmation, :remember_me

  attr_accessible:username
  attr_accessible:first_name
  attr_accessible:last_name
  attr_accessible:address
  attr_accessible :city

  attr_accessible :state_province_id
  attr_accessible :country_id

  attr_accessible:postal_code
  attr_accessible:work_phone
  attr_accessible:home_phone
  attr_accessible:mobile_phone
  attr_accessible:fax

  attr_accessible:company_name
  attr_accessible:work_title
  attr_accessible:license_number

  ###############################################################


  #attr_accessor can be used for values you don't want to store in the database directly and that will only exist for the life of the object (e.g. passwords).
  attr_accessor :email, :password, :password_confirmation, :remember_me
  ###############################################################


  cattr_accessor :time_out_time

  def timeout_in
    if time_out_time.nil?
      STUDENT_LOG_OUT_PERIOD
    else
      time_out_time.seconds
    end
  end
end

The student model in route file:

  devise_for :students, :controllers => { :registrations => "students/registrations" }
  devise_for :students, :controllers => { :sessions => "students/sessions" }

EDIT2:

Here is the student registration controller:

class Students::RegistrationsController < Devise::RegistrationsController

  def update
    # no mass assignment for country_id, we do it manually
    # check for existence of the country in case a malicious user manipulates the params (fails silently)
    if student_signed_in? then
      if params[resource_name][:country_id]
        resource['country_id'] = params[resource_name][:country_id] if Country.find_by_id(params[resource_name][:country_id])
      end
      if params[resource_name][:state_province_id]
        resource.state_province_id = params[resource_name][:state_province_id] if State.find_by_id(params[resource_name][:state_province_id])
      end
    end
    super
  end

  def create
    super
  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-05-29T10:42:23+00:00Added an answer on May 29, 2026 at 10:42 am

    if I remove this line from my Student model:

    attr_accessor :email, :password, :password_confirmation, :remember_me
    

    every thing work fine!, I shouldn’t add attr_accessor , if I add it, devise will not be able to create a new resource from sent parameters.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
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
I have a French site that I want to parse, but am running into

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.