Ask A Question


You’re not receiving notifications from this thread.

How to get param values through radio_buttons ?

rodolfo asked in General

I'm trying to create a TARGET with a responsible user via form_with:

<div class="form-group-users">
    <% @users.each do |user| %>
        <div class="custom-control custom-radio">
            <%= f.radio_button :responsible_id ,'', id:"responsible-manage-#{}", class:'custom-control-input' %>
            <label class="custom-control-label" for="responsible-manage-<%= %>">
                <div class="d-flex align-items-center">
                    <%= image_tag user_avatar(, class:'avatar mr-2', 'data-title' => user.first_name , 'data-toggle':'tooltip' %>
                    <span class="h6 mb-0" data-filter-by="text"><%= user.first_name %> <%= user.last_name %></span>
        <% end %>

The problem here is that params for responsible_id is empty.

Parameters: {"utf8"=>"✓", "authenticity_token"=>"+gh9H09zXkp+W0cUeZO12HDPgWHqWWcVsW+XxD/8o68srfQt/Od0MH/kYNYe6KxQZ2ncFDVq3v5RK267NEPEYw==", "target"=>{"title"=>"Target 2", "description"=>"", "due_date"=>"2018-12-31", "responsible_id"=>"", "team_id"=>""}, "visibility"=>"on", "commit"=>"Create"}

Any ideas?


Hey rodolfo,

You need to add the value you want passed for each radio button. If you check out the docs, you'll see the structure is: radio_button(method, tag_value, options = {})

So your tag should look like this:

<%= f.radio_button :responsible_id ,, id:"responsible-manage-#{}", class:'custom-control-input' %>

Awesome! Thank you @jacob. I love this community.

Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 83,603+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.