Ruby on Rails Sunday, September 29, 2019



On Thursday, September 26, 2019 at 4:53:15 PM UTC-4, M.FURQAN BiN.AMEEN wrote:
I have a complete project as like in ruby on rail with same tables name you can contact with me further on my email 


Best Regards:
MUHAMMAD FURQAN

On Fri, Sep 27, 2019, 1:16 AM fugee ohu <fuge...@gmail.com> wrote:


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 (<fuge...@gmail.com>) 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 rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/512f8b73-e3a4-4e74-95e7-4281e7b54821%40googlegroups.com.

Could I give the join table different value fields for different data types llike text_value, date_value, string_value, ...

--
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 rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/02ff8e61-7024-4b21-a8b0-680507d8cb69%40googlegroups.com.

whats your email

--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0b24a3f1-a1f9-4b23-99c4-bb867259977a%40googlegroups.com.

Ruby on Rails Thursday, September 26, 2019

But what's the actual problem? you say you have some problem but you just pasted code with no indication on where to look. Do you have a render error? do you have the view rendering ok but when you submit it it does not do what you want? if it does not do what you want, what's the excepted vs the actual behaviour?

El jue., 26 sept. 2019 a las 22:24, John Sanderbeck (<bandor535@gmail.com>) escribió:
I agree I can clean up the build but the problem I am having is in the form, not the models...

I need to structure the nested form and I can't seem to figure out the rails syntax...

Just experimenting, and currently, this is the closest I have gotten to what I am trying to do...

  <% @dd_detail.dd_detail_categories.each do |category| %>
    <div class="lunch_order_list_class"><%= category.title.titleize %></div>
    <%= f.fields_for :dd_detail_items do |item| %>
        <%= item.label :title %>
        <%= item.check_box :item_check %>
        <%= item.text_field :item_value %>
        <%= item.text_area :note %>
      <br/>
      <%= item.fields_for :dd_detail_subitems do |subitem| %>
          <%= subitem.label :title %>
          <%= subitem.check_box :item_check %>
          <%= subitem.text_field :item_value %>
          <%= subitem.text_area :note %>
        <br/>
      <% end %>
    <% end %>
    <%= f.fields_for :dd_detail_subcategories do |subcategory| %>
      <%= subcategory.label :title %><br/>
      <%= subcategory.fields_for :dd_detail_items do |item| %>
          <%= item.label :title %>
          <%= item.check_box :item_check %>
          <%= item.text_field :item_value %>
          <%= item.text_area :note %>
        <br/>
        <%= item.fields_for :dd_detail_subitems do |subitem| %>
            <%= subitem.label :title %>
            <%= subitem.check_box :item_check %>
            <%= subitem.text_field :item_value %>
            <%= subitem.text_area :note %>
          <br/>
        <% end %>
      <% end %>
    <% end %>
  <% end %>




On Thursday, September 26, 2019 at 4:25:03 PM UTC-4, Ariel Juodziukynas wrote:
I'm not sure I understand what's the problem, where exactly do you have doubts?

I'd suggest you first refactor that super ugly nested loops and ifs:
- remove the unnecesarry if's
    DdCategory.all.each do |category|
      # If the Category is active, build it
      if category.is_active?

can't you handle that is_active? with a scope?

- the blocks for category.dd_items and subcategory.dd_items looks almost the same, I think you can reuse some code there

- move complex logic to other methods to clean that up, like:

                    item.dd_subitems.each do |subitem|
                      newitem.dd_detail_subitems.create!(dd_detail_item_id: newitem.id, title: subitem.title, has_check: subitem.has_check, has_value: subitem.has_value, has_note: subitem.has_note, item_check: subitem.item_check, item_value: subitem.item_value, item_note: subitem.item_note)
                    end

could be a method on newitem like "add_subitem_from(subitem)" that does that create but you'll have less clutter to simplify your logic to understand it better


El jue., 26 sept. 2019 a las 16:01, John Sanderbeck (<band...@gmail.com>) escribió:

Another thing to note is I am also only doing an Edit of the data as the records already have been created and are not allowed to be destroyed.

John 

--
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 rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/56b5ef26-e7ed-45a8-b346-b39c45edca0f%40googlegroups.com.

--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/424ef245-ea1a-410e-89ca-797bec4712f2%40googlegroups.com.

--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAPS3bcDDVGfEPi9AXkdHeC3ZxhCN6ecqA4smkwKcnoJdw_pBPA%40mail.gmail.com.

Ruby on Rails

I agree I can clean up the build but the problem I am having is in the form, not the models...

I need to structure the nested form and I can't seem to figure out the rails syntax...

Just experimenting, and currently, this is the closest I have gotten to what I am trying to do...

  <% @dd_detail.dd_detail_categories.each do |category| %>
    <div class="lunch_order_list_class"><%= category.title.titleize %></div>
    <%= f.fields_for :dd_detail_items do |item| %>
        <%= item.label :title %>
        <%= item.check_box :item_check %>
        <%= item.text_field :item_value %>
        <%= item.text_area :note %>
      <br/>
      <%= item.fields_for :dd_detail_subitems do |subitem| %>
          <%= subitem.label :title %>
          <%= subitem.check_box :item_check %>
          <%= subitem.text_field :item_value %>
          <%= subitem.text_area :note %>
        <br/>
      <% end %>
    <% end %>
    <%= f.fields_for :dd_detail_subcategories do |subcategory| %>
      <%= subcategory.label :title %><br/>
      <%= subcategory.fields_for :dd_detail_items do |item| %>
          <%= item.label :title %>
          <%= item.check_box :item_check %>
          <%= item.text_field :item_value %>
          <%= item.text_area :note %>
        <br/>
        <%= item.fields_for :dd_detail_subitems do |subitem| %>
            <%= subitem.label :title %>
            <%= subitem.check_box :item_check %>
            <%= subitem.text_field :item_value %>
            <%= subitem.text_area :note %>
          <br/>
        <% end %>
      <% end %>
    <% end %>
  <% end %>




On Thursday, September 26, 2019 at 4:25:03 PM UTC-4, Ariel Juodziukynas wrote:
I'm not sure I understand what's the problem, where exactly do you have doubts?

I'd suggest you first refactor that super ugly nested loops and ifs:
- remove the unnecesarry if's
    DdCategory.all.each do |category|
      # If the Category is active, build it
      if category.is_active?

can't you handle that is_active? with a scope?

- the blocks for category.dd_items and subcategory.dd_items looks almost the same, I think you can reuse some code there

- move complex logic to other methods to clean that up, like:

                    item.dd_subitems.each do |subitem|
                      newitem.dd_detail_subitems.create!(dd_detail_item_id: newitem.id, title: subitem.title, has_check: subitem.has_check, has_value: subitem.has_value, has_note: subitem.has_note, item_check: subitem.item_check, item_value: subitem.item_value, item_note: subitem.item_note)
                    end

could be a method on newitem like "add_subitem_from(subitem)" that does that create but you'll have less clutter to simplify your logic to understand it better


El jue., 26 sept. 2019 a las 16:01, John Sanderbeck (<band...@gmail.com>) escribió:

Another thing to note is I am also only doing an Edit of the data as the records already have been created and are not allowed to be destroyed.

John 

--
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 rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/56b5ef26-e7ed-45a8-b346-b39c45edca0f%40googlegroups.com.

--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/424ef245-ea1a-410e-89ca-797bec4712f2%40googlegroups.com.

Ruby on Rails

You were asking a way to store different values, I thought you wanted to preserve the type (so you can distinguish 1 from "1" when you read the record).

If you think strings are enough for your requirements just use a string column, if you want to use one column to store values but preserve the original type you have to serialize the value somehow (that's the is_a?... when serializing and the case when casting).

Another option is to use two columns: one for the stringified value and one for the original type so you can parse that again.

El jue., 26 sept. 2019 a las 17:57, fugee ohu (<fugee279@gmail.com>) escribió:


On Thursday, September 26, 2019 at 4:32:10 PM UTC-4, Ariel Juodziukynas wrote:
The easiest but too big is a text columns so you can use activerecord' serialization of attributes to save anything you want on a text field and activerecord will handle casting.

You could use a string column if you know your values won't be too big (VARCHAR(255)) and you know what types you want to accept and handle serialization yourself like:

    def value=(something)
      val = if value.is_a?(Integer)
              "integer:#{something}"
            elsif value.is_a?(String)
              "string:#{something}"
            elsif value.is_a?(Date)
              "date:#{something}
            # etc...
      write_attribute(:value, val)
    end

    def value
      type, val = read_attribute(:value).split(':')
      case type
      when "integer" then val.to_i
      when "string" then val
      when "date" then Date.parse(val)
      etc...
    end
           

El jue., 26 sept. 2019 a las 17:17, fugee ohu (<fuge...@gmail.com>) 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 (<fuge...@gmail.com>) 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 rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/512f8b73-e3a4-4e74-95e7-4281e7b54821%40googlegroups.com.

What data type do you suggest for value column

--
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 rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/e74aaf6b-b9e1-4847-a6d3-3120829fa3bc%40googlegroups.com.

 If I'm using a string column then whatever value is put in it is a string, so I don't understand all these "'if value.is_a?" conditions

--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/93726aa7-2667-4f3b-b27c-6d19d5e5f368%40googlegroups.com.

--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAPS3bcDCwk%3DBahS3WQ3a6%2Bkcszzkq_z%2BTkbVxZsMYwf2m6U6Sg%40mail.gmail.com.

Ruby on Rails



On Thursday, September 26, 2019 at 4:32:10 PM UTC-4, Ariel Juodziukynas wrote:
The easiest but too big is a text columns so you can use activerecord' serialization of attributes to save anything you want on a text field and activerecord will handle casting.

You could use a string column if you know your values won't be too big (VARCHAR(255)) and you know what types you want to accept and handle serialization yourself like:

    def value=(something)
      val = if value.is_a?(Integer)
              "integer:#{something}"
            elsif value.is_a?(String)
              "string:#{something}"
            elsif value.is_a?(Date)
              "date:#{something}
            # etc...
      write_attribute(:value, val)
    end

    def value
      type, val = read_attribute(:value).split(':')
      case type
      when "integer" then val.to_i
      when "string" then val
      when "date" then Date.parse(val)
      etc...
    end
           

El jue., 26 sept. 2019 a las 17:17, fugee ohu (<fuge...@gmail.com>) 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 (<fuge...@gmail.com>) 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 rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/512f8b73-e3a4-4e74-95e7-4281e7b54821%40googlegroups.com.

What data type do you suggest for value column

--
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 rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/e74aaf6b-b9e1-4847-a6d3-3120829fa3bc%40googlegroups.com.

 If I'm using a string column then whatever value is put in it is a string, so I don't understand all these "'if value.is_a?" conditions

--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/93726aa7-2667-4f3b-b27c-6d19d5e5f368%40googlegroups.com.

Ruby on Rails

The easiest but too big is a text columns so you can use activerecord' serialization of attributes to save anything you want on a text field and activerecord will handle casting.

You could use a string column if you know your values won't be too big (VARCHAR(255)) and you know what types you want to accept and handle serialization yourself like:

    def value=(something)
      val = if value.is_a?(Integer)
              "integer:#{something}"
            elsif value.is_a?(String)
              "string:#{something}"
            elsif value.is_a?(Date)
              "date:#{something}
            # etc...
      write_attribute(:value, val)
    end

    def value
      type, val = read_attribute(:value).split(':')
      case type
      when "integer" then val.to_i
      when "string" then val
      when "date" then Date.parse(val)
      etc...
    end
           

El jue., 26 sept. 2019 a las 17:17, fugee ohu (<fugee279@gmail.com>) 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 (<fuge...@gmail.com>) 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 rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/512f8b73-e3a4-4e74-95e7-4281e7b54821%40googlegroups.com.

What data type do you suggest for value column

--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/e74aaf6b-b9e1-4847-a6d3-3120829fa3bc%40googlegroups.com.

--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAPS3bcCM%3DSv-%2BExu7_dh2b7nOZhSv67e8YgHKHPqFuch6r%3D-ug%40mail.gmail.com.

Ruby on Rails

[response inline]

On Thu, 26 Sep 2019 at 13:17, fugee ohu <fugee279@gmail.com> wrote:
What data type do you suggest for value column?

There were types suggested by the original responder. However, worrying about column types is an instance of premature optimization. 

Get the basic site working, and then optimize, once you have determined your performance needs. -- H
--
If you wish to request my time, please do so using bit.ly/hd1AppointmentRequest.
Si vous voudrais faire connnaisance, allez a bit.ly/hd1AppointmentRequest.

Sent from my mobile device
Envoye de mon portable

--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAP%2BbYWAZG0R%3D1s9gLEpKwoFBuAggSTmA7fPQL3RQD_Q1csC8Dw%40mail.gmail.com.

Ruby on Rails

I'm not sure I understand what's the problem, where exactly do you have doubts?

I'd suggest you first refactor that super ugly nested loops and ifs:
- remove the unnecesarry if's
    DdCategory.all.each do |category|
      # If the Category is active, build it
      if category.is_active?

can't you handle that is_active? with a scope?

- the blocks for category.dd_items and subcategory.dd_items looks almost the same, I think you can reuse some code there

- move complex logic to other methods to clean that up, like:

                    item.dd_subitems.each do |subitem|
                      newitem.dd_detail_subitems.create!(dd_detail_item_id: newitem.id, title: subitem.title, has_check: subitem.has_check, has_value: subitem.has_value, has_note: subitem.has_note, item_check: subitem.item_check, item_value: subitem.item_value, item_note: subitem.item_note)
                    end

could be a method on newitem like "add_subitem_from(subitem)" that does that create but you'll have less clutter to simplify your logic to understand it better


El jue., 26 sept. 2019 a las 16:01, John Sanderbeck (<bandor535@gmail.com>) escribió:

Another thing to note is I am also only doing an Edit of the data as the records already have been created and are not allowed to be destroyed.

John 

--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/56b5ef26-e7ed-45a8-b346-b39c45edca0f%40googlegroups.com.

--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAPS3bcDL%2Bu4RcvNAEOdAV0q44dnD6OFOJ2BXT%2BoFxhKiyPOuBw%40mail.gmail.com.

Ruby on Rails

I have a complete project as like in ruby on rail with same tables name you can contact with me further on my email 


Best Regards:
MUHAMMAD FURQAN

On Fri, Sep 27, 2019, 1:16 AM fugee ohu <fugee279@gmail.com> wrote:


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 (<fuge...@gmail.com>) 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 rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/512f8b73-e3a4-4e74-95e7-4281e7b54821%40googlegroups.com.

Could I give the join table different value fields for different data types llike text_value, date_value, string_value, ...

--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/02ff8e61-7024-4b21-a8b0-680507d8cb69%40googlegroups.com.

--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAMWiOBt-A5qQ7hX4yDyQemWTNx%3DcW05WzHJF5bTbBYA%2BYzntZg%40mail.gmail.com.

Ruby on Rails



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 (<fuge...@gmail.com>) 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 rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/512f8b73-e3a4-4e74-95e7-4281e7b54821%40googlegroups.com.

What data type do you suggest for value column

--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/e74aaf6b-b9e1-4847-a6d3-3120829fa3bc%40googlegroups.com.

Ruby on Rails



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 (<fuge...@gmail.com>) 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 rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/512f8b73-e3a4-4e74-95e7-4281e7b54821%40googlegroups.com.

Could I give the join table different value fields for different data types llike text_value, date_value, string_value, ...

--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/02ff8e61-7024-4b21-a8b0-680507d8cb69%40googlegroups.com.

Ruby on Rails


Another thing to note is I am also only doing an Edit of the data as the records already have been created and are not allowed to be destroyed.

John 

--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/56b5ef26-e7ed-45a8-b346-b39c45edca0f%40googlegroups.com.

Ruby on Rails

Here is a fun one for everyone...   

I have been struggling developing a form to do the following:

I have a Class with Students in it, and every day the teachers have to fill out a daily detail sheet which looks like this...

Untitled picture.png


Thank you in advance for any thoughts on this one... 

So what I have done is create a data scheme like this

dd_sheet
  dd_details
    dd_detail_categories
      dd_detail_items
       dd_detail_subitems
    dd_detail_subcategories
      dd_detail_items
        dd_detail_subitems

The sheet has the classroom, date and teacher...

The detail has a student, note and then Categories, Subcategories, Items, and Subitems

The Categories, Subcategories, Items, and Subitems are predefined from another set of tables and built when they create a new daily detail sheet

Model wise this all works great, so the relationships are correct

So on the form is where I am having the issue

Base Form is on DailyDetail

Need to step through each Category and display items related to that category first (including subitems related to the items)
Then step through each Subcategory and display items related to that category first (including subitems related to the items) 

Each Item/Subitem can have a check, a value, and/or a note so there is a check as to whether that value is needed. Here is the Item Table definition. Subitem is the same
------------
    create_table :dd_detail_items do |t|
      t.integer :dd_detail_category_id, null: true
      t.integer :dd_detail_subcategory_id, null: true
      t.string :title, null: false, length: 100
      t.boolean :has_check, default: false
      t.boolean :has_value, default: false
      t.boolean :has_note, default: false
      t.boolean :item_check, default: false
      t.string :item_value, default: ''
      t.text :item_note, default: ''
      t.timestamps null: false
    end
-------------

This is driving me bonkers trying to figure out this nesting....  I know logically how it should work but can't figure out the rails syntax to do it correctly...

Here are my models

dd_sheet
------------
  has_many :dd_details, dependent: :destroy
  belongs_to :classroom

  after_commit :build_nested, on: :create

  private

  def build_nested()
    classroom.students.each do |student|
      detail = DdDetail.create!(dd_sheet_id: id, student_id: student.id)
      # For each category, build the Items and Subcategories
      DdCategory.all.each do |category|
        # If the Category is active, build it
        if category.is_active?
          cat = detail.dd_detail_categories.create!(title: category.title)
          # Now build any items directly related to this Category
          category.dd_items.each do |item|
            # If the item is active, build it
            if item.is_active?
              newitem = cat.dd_detail_items.create!(dd_detail_category_id: cat.id, title: item.title, has_check: item.has_check, has_value: item.has_value, has_note: item.has_note, item_check: item.item_check, item_value: item.item_value, item_note: item.item_note)
              # If the item is has SubItems, build them
              if item.dd_subitems.count > 0
                item.dd_subitems.each do |subitem|
                  newitem.dd_detail_subsubitems.create!(dd_detail_item_id: newitem.id, title: subitem.title, has_check: subitem.has_check, has_value: subitem.has_value, has_note: subitem.has_note, item_check: subitem.item_check, item_value: subitem.item_value, item_note: subitem.item_note)
                end
              end
            end
          end
          category.dd_subcategories.each do |subcategory|
            # If the Subcategory is active, build it
            if subcategory.is_active?
              subcat = cat.dd_detail_subcategories.create!(title: subcategory.title)
              subcategory.dd_items.each do |item|
                # If the item is active, build it
                if item.is_active?
                  newitem = subcat.dd_detail_items.create!(dd_detail_category_id: subcat.id, title: item.title, has_check: item.has_check, has_value: item.has_value, has_note: item.has_note, item_check: item.item_check, item_value: item.item_value, item_note: item.item_note)
                  # If the item is has SubItems, build them
                  if item.dd_subitems.count > 0
                    item.dd_subitems.each do |subitem|
                      newitem.dd_detail_subitems.create!(dd_detail_item_id: newitem.id, title: subitem.title, has_check: subitem.has_check, has_value: subitem.has_value, has_note: subitem.has_note, item_check: subitem.item_check, item_value: subitem.item_value, item_note: subitem.item_note)
                    end
                  end
                end
              end
            end
          end
        end
      end  
    end
  end
------------


dd_detail
------------
  belongs_to :dd_sheet
  has_many :dd_detail_categories, dependent: :destroy
  belongs_to :student
------------


dd_detail_category
------------
  belongs_to :dd_detail
  has_many :dd_detail_subcategories, dependent: :destroy
  has_many :dd_detail_items, dependent: :destroy
  accepts_nested_attributes_for :dd_detail_items, allow_destroy: true
------------


dd_detail_subcategories
------------
  belongs_to :dd_detail_category
  has_many :dd_detail_items, dependent: :destroy
  accepts_nested_attributes_for :dd_detail_items, allow_destroy: true
------------


dd_detail_items
------------
  belongs_to :dd_detail_category
  belongs_to :dd_detail_subcategory
  has_many :dd_detail_subitems, dependent: :destroy
  accepts_nested_attributes_for :dd_detail_subitems, allow_destroy: true
------------


dd_detail_subitems
------------
  belongs_to :dd_detail_item
------------


--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/029fe73d-4938-4b56-9c4c-be5e011cc280%40googlegroups.com.

Ruby on Rails

Hi 
Here m available for working with you also have 

Honorable Sir/Madam,

I hope this finds you well.

Please find the enclosed (Muhammad Furqan CV. docx) for your review for position mentioned in the subject line.
Best Regards:
MUHAMMAD FURQAN

On Thu, Sep 26, 2019, 4:20 PM James Tobin <jamesbtobin@gmail.com> wrote:
Hello, I'm working with an employer that is looking to hire a
permanent front end architect to join their London office.  You should
have experience with Javascript and frameworks such as (but not only)
React.  Consequently, I had hoped that some members of this mailing
list may like to discuss further off-list using "JamesBTobin (at)
Gmail (dot) Com".  Kind regards, James

--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAMyPCTR5vPaYP1jVDFxTcVBnG21Ni3ieB54dsB5qqYMspgtYYQ%40mail.gmail.com.

--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAMWiOBugVL8QcOzZ72K-jOaH3XA5-X0jVa60sYAcW_M11JM3XA%40mail.gmail.com.

Ruby on Rails

Hello, I'm working with an employer that is looking to hire a
permanent front end architect to join their London office. You should
have experience with Javascript and frameworks such as (but not only)
React. Consequently, I had hoped that some members of this mailing
list may like to discuss further off-list using "JamesBTobin (at)
Gmail (dot) Com". Kind regards, James

--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAMyPCTR5vPaYP1jVDFxTcVBnG21Ni3ieB54dsB5qqYMspgtYYQ%40mail.gmail.com.

Ruby on Rails

Hi Everyone,

Our use case is we have two option sets. Both can be modified by the user. Optionset1 contains two values. Optionset2 contains a dozen values. We want Optionset2 to show values depending on what value is selected for Optionset1.


When no value is selected for Optionset1, we want Optionset2 to show no values (or be disabled).


We want the user to be able to change values for Optionset1 multiple times during the same session if necessary and always get the corresponding values for Optionset2.

--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/47cdb25a-2fb2-4abf-b66b-72ac8e9205df%40googlegroups.com.

Ruby on Rails Wednesday, September 25, 2019



On Wednesday, September 25, 2019 at 6:05:46 PM UTC-4, Rob Biedenharn wrote:


On 2019-Sep-25, at 14:45 , fugee ohu <fuge...@gmail.com> wrote:



On Friday, September 20, 2019 at 5:13:44 PM UTC-4, Colin Law wrote:
On Fri, 20 Sep 2019 at 18:10, fugee ohu <fuge...@gmail.com> wrote:
>
> How do I keep a record of the original creation date? What if I wanna preserve the original creation date?
od
Each record in the database has a created_at field.  At least mine do.

Colin

I want the creation date of file before it's uploaded Can you tell me how to find it I know it has something to do with ruby mtime function

You can't get that information in the browser. The best you could do is the lastModified time of the file.





-Rob


  They talk about cases where the last modified time isn't available What kind of device might someone be uploading a file from that doesn't have a last modified date for a file I never saw a file without a last modified date

--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/b52f5309-7aad-45cc-93f4-684b244947ca%40googlegroups.com.

Ruby on Rails



On 2019-Sep-25, at 14:45 , fugee ohu <fugee279@gmail.com> wrote:



On Friday, September 20, 2019 at 5:13:44 PM UTC-4, Colin Law wrote:
On Fri, 20 Sep 2019 at 18:10, fugee ohu <fuge...@gmail.com> wrote:
>
> How do I keep a record of the original creation date? What if I wanna preserve the original creation date?
od
Each record in the database has a created_at field.  At least mine do.

Colin

I want the creation date of file before it's uploaded Can you tell me how to find it I know it has something to do with ruby mtime function

You can't get that information in the browser. The best you could do is the lastModified time of the file.





-Rob

Ruby on Rails



On Friday, September 20, 2019 at 5:13:44 PM UTC-4, Colin Law wrote:
On Fri, 20 Sep 2019 at 18:10, fugee ohu <fuge...@gmail.com> wrote:
>
> How do I keep a record of the original creation date? What if I wanna preserve the original creation date?
od
Each record in the database has a created_at field.  At least mine do.

Colin

I want the creation date of file before it's uploaded Can you tell me how to find it I know it has something to do with ruby mtime function

--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/b27faa71-8872-4ea7-83bc-b70bc787a43d%40googlegroups.com.

Ruby on Rails



On Tuesday, September 24, 2019 at 7:18:11 PM UTC-4, Ariel Juodziukynas wrote:
Another option (if your database accepts it, like postgres or newer MySQL versions) is to use a column with JSON or JSONB type. You could have a json object with all property/value pairs. I'm not sure about performance, indexing, etc on JSON columns though.

I'm not sure what are the categories you are talking about now, you mean the "auction type"?

You'll have to have many many millions of auctions in order to make the auction_properties tables too large (if your ID is an int, you have 2,000 MILLION ids to use, if you use bigint I don't even know that number, you'll need really good indexes though haha), and even if you ever get near some critical situation you could split table by auction type or something like that. I doubt it's something you have to worry about right now, you'll have a lot of more important things to improve before reaching that.

El mar., 24 sept. 2019 a las 19:19, fugee ohu (<fuge...@gmail.com>) escribió:


On Tuesday, September 24, 2019 at 12:37:37 AM UTC-4, hasan...@gmail.com wrote:
[response inline]

On Mon, 23 Sep 2019 at 21:32, fugee ohu <fuge...@gmail.com> wrote:
But then a single item will contain many records, one for each property, wouldn't that create too-large-tables?

By the time that becomes a problem, you'll have bigger things to worry about it, mate. -- H 

--
If you wish to request my time, please do so using bit.ly/hd1AppointmentRequest.
Si vous voudrais faire connnaisance, allez a bit.ly/hd1AppointmentRequest.

Sent from my mobile devicet t
Envoye de mon portable

 I can't make up my mind First, there's countless types of items Next they may use the category in deciding which form to load We haven't take categories into account  yet in this discussion

--
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 rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/63f7e9f5-eb9a-4618-8ed9-d1f78f3a05b8%40googlegroups.com.

When you sell something on ebay there's no multiple choice of item type to sell, they figure out the type of item and the category from the title you provide but then ask you to confirm or change the category At this primitive stage I was thinking of adding an intermediate page to the new action to allow the user to select the type or category and then when they submit that page the relevant form will be on the next page There's such a thing as fallback also so I think I should build a rest framework first, I don't know

--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/38466182-5166-4205-9e65-22af3c4a3d6b%40googlegroups.com.

Ruby on Rails Tuesday, September 24, 2019

Another option (if your database accepts it, like postgres or newer MySQL versions) is to use a column with JSON or JSONB type. You could have a json object with all property/value pairs. I'm not sure about performance, indexing, etc on JSON columns though.

I'm not sure what are the categories you are talking about now, you mean the "auction type"?

You'll have to have many many millions of auctions in order to make the auction_properties tables too large (if your ID is an int, you have 2,000 MILLION ids to use, if you use bigint I don't even know that number, you'll need really good indexes though haha), and even if you ever get near some critical situation you could split table by auction type or something like that. I doubt it's something you have to worry about right now, you'll have a lot of more important things to improve before reaching that.

El mar., 24 sept. 2019 a las 19:19, fugee ohu (<fugee279@gmail.com>) escribió:


On Tuesday, September 24, 2019 at 12:37:37 AM UTC-4, hasan...@gmail.com wrote:
[response inline]

On Mon, 23 Sep 2019 at 21:32, fugee ohu <fuge...@gmail.com> wrote:
But then a single item will contain many records, one for each property, wouldn't that create too-large-tables?

By the time that becomes a problem, you'll have bigger things to worry about it, mate. -- H 

--
If you wish to request my time, please do so using bit.ly/hd1AppointmentRequest.
Si vous voudrais faire connnaisance, allez a bit.ly/hd1AppointmentRequest.

Sent from my mobile device
Envoye de mon portable

 I can't make up my mind First, there's countless types of items Next they may use the category in deciding which form to load We haven't take categories into account  yet in this discussion

--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/63f7e9f5-eb9a-4618-8ed9-d1f78f3a05b8%40googlegroups.com.

--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAPS3bcDahpvTP45hFT6Gi58iaWL2TTXJGxYsqJeWvojQy%2B31%2BQ%40mail.gmail.com.

Ruby on Rails



On Tuesday, September 24, 2019 at 12:37:37 AM UTC-4, hasan...@gmail.com wrote:
[response inline]

On Mon, 23 Sep 2019 at 21:32, fugee ohu <fuge...@gmail.com> wrote:
But then a single item will contain many records, one for each property, wouldn't that create too-large-tables?

By the time that becomes a problem, you'll have bigger things to worry about it, mate. -- H 

--
If you wish to request my time, please do so using bit.ly/hd1AppointmentRequest.
Si vous voudrais faire connnaisance, allez a bit.ly/hd1AppointmentRequest.

Sent from my mobile device
Envoye de mon portable

 I can't make up my mind First, there's countless types of items Next they may use the category in deciding which form to load We haven't take categories into account  yet in this discussion

--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/63f7e9f5-eb9a-4618-8ed9-d1f78f3a05b8%40googlegroups.com.