On Sunday, October 27, 2019 at 11:52:58 AM UTC-4, Ariel Juodziukynas wrote:
>
> Read about the `fields_for` helper on actionview and the 
> `accepts_nested_attributes_for` macro on activerecord to handle nested 
> forms (fields_for to create the form, accepts_nested_attributes_for so 
> activerecord handles the associated objects creation).
>
>
> https://api.rubyonrails.org/classes/ActionView/Helpers/FormBuilder.html#method-i-fields_for
>
> https://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html#method-i-accepts_nested_attributes_for
>
>
> El dom., 27 oct. 2019 a las 12:47, fugee ohu (<[email protected] 
> <javascript:>>) escribió:
>
>>
>>
>> On Monday, September 16, 2019 at 4:31:29 PM UTC-4, Ariel Juodziukynas 
>> wrote:
>>>
>>> Personally, I would do this:
>>>
>>> auctions table
>>> (with the basic shared information of all auctions and an "auction 
>>> type"))
>>>
>>> properties table
>>> property_name (like network, carrier, publisher, etc)
>>> auction_type (like cellphone, book, etc)
>>>
>>> auctions_properties
>>> auction_id
>>> property_id
>>> value
>>>
>>> That way you can have any number of auction types with any number of 
>>> specific properties with just 3 tables.
>>>
>>> Note that the "value" column would be some string variation (VARCHAR, 
>>> CHAR, TEXT, etc) depending on your needs, maybe you want to redesign it a 
>>> little if you want to store different types. Like if you want to store an 
>>> integer (and retrieve an integer) you'll have to save the original type and 
>>> reparse it (you could use serialization but that requires a TEXT column and 
>>> maybe you can't use that many space)
>>>
>>> El lun., 16 sept. 2019 a las 17:19, fugee ohu (<[email protected]>) 
>>> escribió:
>>>
>>>> I was looking at some auction projects that use a single listings table 
>>>> for all auctions but I know on auction sites the form will be different 
>>>> for 
>>>> different types of items like if you're selling a cell phone there'll be a 
>>>> form field for network, carrier, whatever and if you're selling a book 
>>>> there'll be form fields for publisher, year of publication,  so they would 
>>>> have separate tables I assume for books, cell phones, etc? Then how would 
>>>> they treat them all as one?
>>>>
>>>> -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "Ruby on Rails: Talk" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to [email protected].
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/rubyonrails-talk/512f8b73-e3a4-4e74-95e7-4281e7b54821%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/rubyonrails-talk/512f8b73-e3a4-4e74-95e7-4281e7b54821%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>>
>> How would I collect all the auction_propertes fields on a single form 
>> since they all represent additional records in the auction_properties table 
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Ruby on Rails: Talk" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/rubyonrails-talk/fad5e82f-223a-456f-af18-d1e42529b3f0%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/rubyonrails-talk/fad5e82f-223a-456f-af18-d1e42529b3f0%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
I don't know, it seems this comes down to one form for multiple records 
being inserted into the auction_properties table 

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/bb6b8657-ac63-4bc3-87ba-55dc4e691729%40googlegroups.com.

Reply via email to