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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:40:04+00:00 2026-05-28T06:40:04+00:00

This is happening in an Approval model. Approval has an attribute for :email. So

  • 0

This is happening in an Approval model. Approval has an attribute for :email. So saying self.email is calling an Object of the Approval class with its email attribute.enter code here

def associate_correct_user
    new_user = User.find_or_create_by_email self.email do |u|
      u.invite!
end

If I am creating a user here I need to pass two other attributes (first_name and last_name). Those attributes need to be pulled from another model Email, for which self.email as already been validated against.

this is what makes sense in my head:

def associate_correct_user
    new_user = User.find_or_create_by_email self.email do |u|
       user = Email.find_by_email(self.email)
       u.first_name = user.first_name
       u.last_name = user.last_name
      u.invite!
end

This creates the user, but does not set the first_name and last_name attributes to this new user…

  • 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-28T06:40:04+00:00Added an answer on May 28, 2026 at 6:40 am

    Show me the lines of your log/development.log when the user is created. May be first_name and last_name are protected attributes.
    Here you have an example of find_or_create_by http://api.rubyonrails.org/classes/ActiveRecord/Base.html#label-Dynamic+attribute-based+finders
    It uses a different syntax.

    User.find_or_create_by_name('Bob', :age => 40) { |u| u.admin = true }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have no idea why this is happening. I have some very straightforward code,
I am curious to know why this is happening. Please read the code example
I've heard about this happening in non thread-safe code due to improperly constructed objects
Could someone please explain why this happening: class Apple { String type; setType(){ System.out.println(inside
I have this piece of code : Dictionary<string, object> tempDict = new Dictionary<string, object>();
I'm sure I saw this happening to me once. In a 64-bit OS with
This is happening on Vista. I created a new dialog based MFC project to
This is happening in python files. For example, I want to do type fC
How can I stop this from happening, it is grabbing files in .svn folders
I don't know why this is happening, but when I create a new form

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.