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

The Archive Base Latest Questions

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

I have the following code: def create @user = User.new(params[:user]) simp_ = User.new(params[:user]) if

  • 0

I have the following code:

def create
    @user = User.new(params[:user])
    simp_ = User.new(params[:user])
    if @user.gender.blank?
       load './bayes.rb'
       b_obj= Bayes.new
       simp_.gender = b_obj.predict(@user.height, @user.weight)
       predict_(simp_)
    else
      if @user.save
        redirect_to @user
      else
        @title = "Train"
        render 'new'
      end
    end
  end
 ...

  def predict_(_user)
    @user = _user
    render 'predicted' ( I am printing @user.gender here)
  end

Everything works fine and I am able to use user defined class bayes as well. The problem is that the value stored in ‘simp_.gender’ always remain the same, no matter what my function returns. This is causing a lot of problems.

How should I handle this?

Arun

  • 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-28T18:45:24+00:00Added an answer on May 28, 2026 at 6:45 pm

    First double-check the value returned by b_obj.predict:

    gender = b_obj.predict(@user.height, @user.weight)
    logger.info "GENDER: #{gender}"
    simp_.gender = gender
    

    Try it, then look at the log. If you still need help, edit your question and add information on what was written to the log.

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

Sidebar

Related Questions

I have the following code: #!/usr/bin/ruby class Person def self.speak p = self.new puts
I have the following hypothetical code: class User < ActiveRecord::Base def oauth_consumer @oauth_consumer ||=
I have the following code: def show @game = $site.new_game_of_type(params[:id]) @game.start end def update_game_time
i have the following code def get(self): date = datetime.date.today() loc_query = Location.all() last_cursor
Let's say I have the following ruby code : def use_object(object) puts object.some_method end
I have the following code: class IncidentTag: def __init__(self,tag): self.tag = tag def equals(self,obj):
Let's say that I have the following code in application_helper.rb : def do_something if
I have the following example code: class A(object): def __init__(self, id): self.myid = id
I have the following postscript code: /outputtext { /data exch def /rot exch def
If I have the following piece of Ruby code: class Blah def self.bleh @blih

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.