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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:13:58+00:00 2026-06-16T00:13:58+00:00

This a dumb question but even after some research i can’t fix this problem.

  • 0

This a dumb question but even after some research i can’t fix this problem.
I have a form in one of my view that allow me to get a value from a visitor.
I’m trying to get that value submitted in the form in my controller. And I don’t understand
why but it seems that the only value that I get with this code is 0..
I think I don’t use the correct synthax.
Here is my code from the view :

.mybox
            %p Tentative de vote.
            = @useful_tool.nbofrate
            = @useful_tool.nbtotal
            = @useful_tool.newrate
            = form_for(@useful_tool) do |f|
              = f.select :newrate, [['1 étoile', 1],['2 étoiles', 2],['3 étoiles', 3],['4 étoiles', 4],['5 étoiles', 5]]
              = f.submit

Here is my code from my controller :

  def update
    @useful_tool = UsefulTool.find_by_slug!(params[:id])
    @useful_tool.nbofrate = @useful_tool.nbofrate + 1
    value = params[:newrate]
    @useful_tool.nbtotal += value.to_i
    @useful_tool.rating = @useful_tool.nbtotal / @useful_tool.nbofrate
    update! { url_for(action: "index") }
  end

Because apparantly value must be nil I don’t understand why.
Any help would be very apreciate. Thanks a lot.

  • 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-16T00:13:58+00:00Added an answer on June 16, 2026 at 12:13 am

    try to use to_s.to_d with nbtotal and value.

    or you can explicitly check for nil

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

Sidebar

Related Questions

I have that this is a dumb question feeling, but here goes ... Can
Hey this is probably a dumb question but i can't seem to find a
This might sound like a reaaaally dumb question but... why do browsers have a
This might be a dumb question but I can't get this super simple script
This might be a dumb question, but I don't get it: I have a
I don't know if this is a dumb question but I have this two
This is probably a dumb question, but I can't seem to find a good
This may seem like a dumb question, or even subjective, but I'm not sure
This is probably a dumb question but can I do away safely with just
This is probably a dumb question but can't find an answer with google. Left

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.