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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:16:19+00:00 2026-05-13T22:16:19+00:00

Just thinking about the best way to build an Order form that would (from

  • 0

Just thinking about the best way to build an Order form that would (from user-perspective):

  • Allow adding multiple items.
  • Each item has Name, Job Type drop-down and File upload.
  • User can add or remove items.
  • User must provide at least one item.
  • All the items should be validated (eg: Name, JobType and File are required).
  • When he hits the Submit, an Order should be created with all the items in it.

So the model looks like: User -1---*-Order-1---*- OrderItem-*--1-JobType. Additionally OrderItem includes number of attributes, let’s say name, file.


Now I would like to have as skinny controller as possible. Better with the ‘standard’ code like:

class OrdersController < ApplicationController
  def create
    @order = Order.new(params[:order])
    if @order.save
      redirect_to account_url
    else
      flash.now[:error] = "Could not save Order"
      render :action => "new"
    end
  end
end

The most interesting thing is how a view should look like so that rails automatically binds all the values posted to the correct objects?

For now I don’t worry about degradation from JavaScript, but rather the template for the items to be added and linking all that with the validation (probably as a partial).

I expect a template to look like the one below, but not sure.

<input type='text' name='order[order_items[name[]]][]' />
<select name='order[order_items[job_type[]]][]'>...</select>
<input type='file' name='order[order_items[file[]]][]' />

I have to clone this template in order to add item using JS.


So the answer should:

  • Include the view or part of it that demonstrates:
    • correct binding of the post values;
    • correct validation for all items;
  • Include related part of model.
  • Include changes to the controller IF and ONLY IF necessary.
  • (JavaScript is not required)

Ideally I would like to see a sample if somebody knows one (maybe somewhere on GitHub).

And the last note, please, check your solutions before posting.

Thanks,
Dmitriy.

  • 1 1 Answer
  • 1 View
  • 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-13T22:16:20+00:00Added an answer on May 13, 2026 at 10:16 pm

    Not answering the question directly, but here are some sources to get you there:

    • Railscasts: Nested Model Form Part 1
    • Railscasts: Nested Model Form Part 2
    • Railscasts: Complex Forms Part 3

    On a personal note. Your question comes across as asking for someone to do your work for you. I would gladly post an answer to cover all your needs if I was on the clock.

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

Sidebar

Related Questions

I'm just thinking about the best way to go about sanitizing my data to
I'm just wondering what are you thinking about DIV-tag inside FORM-tag? I need something
I've been thinking about this and I just can't think of a way to
Just curious about the best way to go about this. I want to make
I'm just thinking about the styling and performance. Previously I used to write something
This is probably just wishful thinking... Is there any way to check to see
This was just what I was thinking for this solution and I would like
I am thinking about some issues which may match the term software integration best.
I'm quite new to objective-c so i'm thinking a lot about best practices. My
I was wondering about the best way to setup to following. I have a

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.