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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:29:57+00:00 2026-05-24T12:29:57+00:00

I am using Rails 3.0, Ruby 1.9.2 and the Plataformatec simple_form gem. This code

  • 0

I am using Rails 3.0, Ruby 1.9.2 and the Plataformatec simple_form gem. This code works with a form_for but not simple_form_for:

<%= simple_form_for(@provider) do |f| %>
  <% Car.all.each do |c| %>
    <div>
      <%= check_box_tag :car_ids, c.id, @store.cars.include?(c), :name => 'store[car_ids][]' %>
      $<%= c.cost %> | <%= c.description %>
    </div>
  <% end %>
  <div class="actions">
    <%= f.submit "New" %>
  </div>
<% end %>

How do I get it to work with simple_form_for?

Thanks in advance!

  • 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-24T12:29:58+00:00Added an answer on May 24, 2026 at 12:29 pm

    The problem was in the controller code.

    In the “new” controller action I can’t simply perform:

    @provider = Provider.new(params[:provider])
    

    as one would normally.

    Instead I have to process each parameter separately:

    @provider.location = params[:provider][:location]
    etc…

    For the Car check boxes, I add each car_id from the car_ids parameter to the “has_many” cars model association one at a time:

    car_ids = params[:provider][:car_ids]
    car_ids.each do |cid|
      @provider.cars << Car.find(cid)
    end
    

    Then I can call:

    @provider.save!
    

    And it saves correctly (my initial problem was that it wasn’t saving the selected Cars).

    For some reason, I was able to figure this out only after posting the question here. Funny how that works.

    Thanks all for your replies!

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

Sidebar

Related Questions

I am using Rails 3.0, Ruby 1.9.2 and the Plataformatec simple_form gem. The code
Using Rails 3.2.0.rc2 and ruby 1.9.3p0 In app/views/requests/_form.html.erb I have the following code for
I was trying to switch the layout using Ruby on Rails but I am
Curious as to how to approach this same problem using ruby / rails -
Novice here! I'm currently creating an application using Ruby on Rails. This particular application
I have a Ruby application (not using Rails) that use my own Ruby gems.
says if i develop a Ruby on Rails application using Rails 2.3.2, will that
So I installed Ruby On Rails using the Windows Installer. Now the startup guides
using Ruby on Rails 2.3.2, since I already created Scaffold for Story, so instead
I am using Ruby on Rails. I want to create a filter field on

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.