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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:47:59+00:00 2026-05-23T09:47:59+00:00

Trying to save data from a form to the database. Using the select_tag <%=

  • 0

Trying to save data from a form to the database.
Using the select_tag

<%= select_tag :size, options_from_collection_for_select(@plan, 'name', 'size') %>

Everything is fine, it grabs both size and email ,but when I try to store the data from the form (size), it passes NULL.

Here’s my console:

Started POST "/users" for 127.0.0.1 at 2011-06-24 07:25:29 -0500
Processing by UserController#create as HTML
Parameters: {"utf8"=>"✓",   "authenticity_token"=>"MfT3gs5TtR+bvpaLro0E8Qm1zojaY2ms9WK0WprKPAw=", "size"=>"small",
"user"=>{"email"=>"5@gmail.com"}, "commit"=>"Create User"}
AREL (0.4ms)  INSERT INTO "users" ("email", "size", "created_at", "updated_at") VALUES
 ('5@gmail.com', NULL, '2011-06-24 12:25:29.646814', '2011-06-24 12:25:29.646814')
Redirected to http://localhost:3000/users/14
Completed 302 Found in 56ms

So, It gets the correct data from the form, as you see “size”=>”small”, but when its time to store it, it passes it as NULL,

 VALUES ('5@gmail.com', NULL, '2011-06-24

I thought, it was the select_tag, as it doesnt have u attached, as text_field does

<%= form_for @user do |u| %>
                    <%= render 'shared/error_messages' %>
                        <p><%= u.label :size, 'How many employees do you have?' %>: </p>
                        <p><%= select_tag :size, options_from_collection_for_select(@plan, 'name', 'size') %></p>

                        <p><%= u.label :email, 'What\'s your email address?' %>:</p>
                        <p><%= u.text_field :email %></p>
                        <%= u.submit%>
                    <% end %>

But when I tried u.select_tag = Error, undefined method.

My model

  class User < ActiveRecord::Base
attr_accessible :size, :email
end

Any thoughts?

  • 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-23T09:47:59+00:00Added an answer on May 23, 2026 at 9:47 am

    You need to have the “size” param nested inside of the “users” hash. When you look in the log you want to verify seeing something like this:

    "user"=>{"email"=>"5@gmail.com", "size"=>"small"}
    

    To achieve that inside of of your form for, you can keep your existing select_tag and scope it as such:

    <%= select_tag 'user[size]', options_from_collection_for_select(@plan, 'name', 'size') %>
    

    Or you for this case it looks like you could use collection_select scoped on the form object:

    <%= u.collection_select :size, @plan, :name, :size %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.