Ruby on Rails Sunday, September 30, 2012

Hi all,

I have two models, Item and Bid


class Item
  include Mongoid::Document
  field :name, type: String
  has_many :bids 
end
class Bid
  include Mongoid::Document
  include Mongoid::Timestamps::Created
  field :bid, type: Float
  belongs_to :item  
end

In views/prices/index I would like to list all items in a table and for each item put a field next it in which people can enter a number. At the bottom of the form should be a submit button for all records.

How is this best achieved?

There's plenty of code out there explaining how to add, for instance, several questions to one survey but I couldn't find an example that shows how to add one new record for each of of an existing element of a collection. 

Thanks...

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/adUQnc0M9R8J.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment