Ruby on Rails Thursday, October 31, 2019



On Friday, November 1, 2019 at 12:12:18 AM UTC-4, Ariel Juodziukynas wrote:
If you have:
item has_many item_item_properties
item_item_property belongs_to item_property

then you can add a relationship on the item model

has_many :item_properties, through: :item_item_properties

Then you'll be able to call @item.item_properties to loop through the ItemProperty objects associated to that Item object.

Now, you say @item.item_item_properties.pluck(:item_property_id) returns an empty array, that's because the Item does not have associated properties and pluck does an SQL.

El vie., 1 nov. 2019 a las 0:52, fugee ohu (<fuge...@gmail.com>) escribió:


On Thursday, October 31, 2019 at 11:32:22 PM UTC-4, Ariel Juodziukynas wrote:
You can do @item.item_item_properties.each do |item_item_property| and handle that object inside the loop, I'm not sure why would you expect that item_item_properties relationship to return key, value pairs. I don't understand what you want to achieve, maybe you are trying to do it on the wrong path.

El vie., 1 nov. 2019 a las 0:27, fugee ohu (<fuge...@gmail.com>) escribió:


On Thursday, October 31, 2019 at 9:33:22 PM UTC-4, Ariel Juodziukynas wrote:
@item.item_item_properties returns a collection of objects, you are calling a method on something array-like, it makes no sense.

If you want to get all the item_property_ids you can do @item.item_item_properties.pluck(:item_property_id) for example. I'm not sure what you want to achieve.

El jue., 31 oct. 2019 a las 22:29, fugee ohu (<fuge...@gmail.com>) escribió:


On Thursday, October 31, 2019 at 2:15:48 PM UTC-4, Ariel Juodziukynas wrote:
Use `.size` instead of `.count`. "count" does a database query and since you only built the element the COUNT db query will return 0. "size" knows what to do if the association is already initialized so it will return "1" in your case (and if it's not already loaded it will run a COUNT db query).

El jue., 31 oct. 2019 a las 8:42, fugee ohu (<fuge...@gmail.com>) escribió:
> @item=Item.new
> @item.item_item_properties.build
> @item.item_item_properties.count
 => 0

Why doesn't my @item object have any item_item_properties after build method

--
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/161b90ed-b6b1-4d4d-9f67-fb70f0463621%40googlegroups.com.

How do I reference individual columns?
 2.3.3 :006 > @item.item_item_properties.item_property_id
NoMethodError: undefined method `item_property_id' for #<ItemItemProperty::ActiveRecord_Associations_CollectionProxy:0x0055d4167fd628>

--
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/a80b3961-82df-4943-9e5a-adb764d516b7%40googlegroups.com.

Could I directly access key, value without pluck or otherwise like
 @item.item_item_properties.each do |key, value|
item_property_id

--
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/b2057f01-80e0-4816-8893-b783e30159f8%40googlegroups.com.

Display item_property attributes in form

--
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/3a2c3dcf-3b21-49c9-8e49-9b2f276d7b6d%40googlegroups.com.

There are no database records yet, we know, the object was instantiated by the build method but so far I don't see how to read it's data for my views

--
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/7e40c90a-3a1b-4844-8c19-d1b02eef347c%40googlegroups.com.

Ruby on Rails

If you have:
item has_many item_item_properties
item_item_property belongs_to item_property

then you can add a relationship on the item model

has_many :item_properties, through: :item_item_properties

Then you'll be able to call @item.item_properties to loop through the ItemProperty objects associated to that Item object.

Now, you say @item.item_item_properties.pluck(:item_property_id) returns an empty array, that's because the Item does not have associated properties and pluck does an SQL.

El vie., 1 nov. 2019 a las 0:52, fugee ohu (<fugee279@gmail.com>) escribió:


On Thursday, October 31, 2019 at 11:32:22 PM UTC-4, Ariel Juodziukynas wrote:
You can do @item.item_item_properties.each do |item_item_property| and handle that object inside the loop, I'm not sure why would you expect that item_item_properties relationship to return key, value pairs. I don't understand what you want to achieve, maybe you are trying to do it on the wrong path.

El vie., 1 nov. 2019 a las 0:27, fugee ohu (<fuge...@gmail.com>) escribió:


On Thursday, October 31, 2019 at 9:33:22 PM UTC-4, Ariel Juodziukynas wrote:
@item.item_item_properties returns a collection of objects, you are calling a method on something array-like, it makes no sense.

If you want to get all the item_property_ids you can do @item.item_item_properties.pluck(:item_property_id) for example. I'm not sure what you want to achieve.

El jue., 31 oct. 2019 a las 22:29, fugee ohu (<fuge...@gmail.com>) escribió:


On Thursday, October 31, 2019 at 2:15:48 PM UTC-4, Ariel Juodziukynas wrote:
Use `.size` instead of `.count`. "count" does a database query and since you only built the element the COUNT db query will return 0. "size" knows what to do if the association is already initialized so it will return "1" in your case (and if it's not already loaded it will run a COUNT db query).

El jue., 31 oct. 2019 a las 8:42, fugee ohu (<fuge...@gmail.com>) escribió:
> @item=Item.new
> @item.item_item_properties.build
> @item.item_item_properties.count
 => 0

Why doesn't my @item object have any item_item_properties after build method

--
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/161b90ed-b6b1-4d4d-9f67-fb70f0463621%40googlegroups.com.

How do I reference individual columns?
 2.3.3 :006 > @item.item_item_properties.item_property_id
NoMethodError: undefined method `item_property_id' for #<ItemItemProperty::ActiveRecord_Associations_CollectionProxy:0x0055d4167fd628>

--
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/a80b3961-82df-4943-9e5a-adb764d516b7%40googlegroups.com.

Could I directly access key, value without pluck or otherwise like
 @item.item_item_properties.each do |key, value|
item_property_id

--
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/b2057f01-80e0-4816-8893-b783e30159f8%40googlegroups.com.

Display item_property attributes in form

--
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/3a2c3dcf-3b21-49c9-8e49-9b2f276d7b6d%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/CAPS3bcBL5tp8T2_TG5f65OjDRUO03CeW08T3GHAVwMeNq%2BETGg%40mail.gmail.com.

Ruby on Rails



On Thursday, October 31, 2019 at 11:32:22 PM UTC-4, Ariel Juodziukynas wrote:
You can do @item.item_item_properties.each do |item_item_property| and handle that object inside the loop, I'm not sure why would you expect that item_item_properties relationship to return key, value pairs. I don't understand what you want to achieve, maybe you are trying to do it on the wrong path.

El vie., 1 nov. 2019 a las 0:27, fugee ohu (<fuge...@gmail.com>) escribió:


On Thursday, October 31, 2019 at 9:33:22 PM UTC-4, Ariel Juodziukynas wrote:
@item.item_item_properties returns a collection of objects, you are calling a method on something array-like, it makes no sense.

If you want to get all the item_property_ids you can do @item.item_item_properties.pluck(:item_property_id) for example. I'm not sure what you want to achieve.

El jue., 31 oct. 2019 a las 22:29, fugee ohu (<fuge...@gmail.com>) escribió:


On Thursday, October 31, 2019 at 2:15:48 PM UTC-4, Ariel Juodziukynas wrote:
Use `.size` instead of `.count`. "count" does a database query and since you only built the element the COUNT db query will return 0. "size" knows what to do if the association is already initialized so it will return "1" in your case (and if it's not already loaded it will run a COUNT db query).

El jue., 31 oct. 2019 a las 8:42, fugee ohu (<fuge...@gmail.com>) escribió:
> @item=Item.new
> @item.item_item_properties.build
> @item.item_item_properties.count
 => 0

Why doesn't my @item object have any item_item_properties after build method

--
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/161b90ed-b6b1-4d4d-9f67-fb70f0463621%40googlegroups.com.

How do I reference individual columns?
 2.3.3 :006 > @item.item_item_properties.item_property_id
NoMethodError: undefined method `item_property_id' for #<ItemItemProperty::ActiveRecord_Associations_CollectionProxy:0x0055d4167fd628>

--
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/a80b3961-82df-4943-9e5a-adb764d516b7%40googlegroups.com.

Could I directly access key, value without pluck or otherwise like
 @item.item_item_properties.each do |key, value|
item_property_id

--
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/b2057f01-80e0-4816-8893-b783e30159f8%40googlegroups.com.

Display item_property attributes in form

--
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/3a2c3dcf-3b21-49c9-8e49-9b2f276d7b6d%40googlegroups.com.

Ruby on Rails



On Thursday, October 31, 2019 at 9:33:22 PM UTC-4, Ariel Juodziukynas wrote:
@item.item_item_properties returns a collection of objects, you are calling a method on something array-like, it makes no sense.

If you want to get all the item_property_ids you can do @item.item_item_properties.pluck(:item_property_id) for example. I'm not sure what you want to achieve.

El jue., 31 oct. 2019 a las 22:29, fugee ohu (<fuge...@gmail.com>) escribió:


On Thursday, October 31, 2019 at 2:15:48 PM UTC-4, Ariel Juodziukynas wrote:
Use `.size` instead of `.count`. "count" does a database query and since you only built the element the COUNT db query will return 0. "size" knows what to do if the association is already initialized so it will return "1" in your case (and if it's not already loaded it will run a COUNT db query).

El jue., 31 oct. 2019 a las 8:42, fugee ohu (<fuge...@gmail.com>) escribió:
> @item=Item.new
> @item.item_item_properties.build
> @item.item_item_properties.count
 => 0

Why doesn't my @item object have any item_item_properties after build method

--
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/161b90ed-b6b1-4d4d-9f67-fb70f0463621%40googlegroups.com.

How do I reference individual columns?
 2.3.3 :006 > @item.item_item_properties.item_property_id
NoMethodError: undefined method `item_property_id' for #<ItemItemProperty::ActiveRecord_Associations_CollectionProxy:0x0055d4167fd628>

--
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/a80b3961-82df-4943-9e5a-adb764d516b7%40googlegroups.com.

 2.3.3 :006 > @item.item_item_properties.pluck(:item_property_id)
 => []

--
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/6d62e08d-57b2-4584-9271-e89aa6ca17be%40googlegroups.com.

Ruby on Rails

You can do @item.item_item_properties.each do |item_item_property| and handle that object inside the loop, I'm not sure why would you expect that item_item_properties relationship to return key, value pairs. I don't understand what you want to achieve, maybe you are trying to do it on the wrong path.

El vie., 1 nov. 2019 a las 0:27, fugee ohu (<fugee279@gmail.com>) escribió:


On Thursday, October 31, 2019 at 9:33:22 PM UTC-4, Ariel Juodziukynas wrote:
@item.item_item_properties returns a collection of objects, you are calling a method on something array-like, it makes no sense.

If you want to get all the item_property_ids you can do @item.item_item_properties.pluck(:item_property_id) for example. I'm not sure what you want to achieve.

El jue., 31 oct. 2019 a las 22:29, fugee ohu (<fuge...@gmail.com>) escribió:


On Thursday, October 31, 2019 at 2:15:48 PM UTC-4, Ariel Juodziukynas wrote:
Use `.size` instead of `.count`. "count" does a database query and since you only built the element the COUNT db query will return 0. "size" knows what to do if the association is already initialized so it will return "1" in your case (and if it's not already loaded it will run a COUNT db query).

El jue., 31 oct. 2019 a las 8:42, fugee ohu (<fuge...@gmail.com>) escribió:
> @item=Item.new
> @item.item_item_properties.build
> @item.item_item_properties.count
 => 0

Why doesn't my @item object have any item_item_properties after build method

--
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/161b90ed-b6b1-4d4d-9f67-fb70f0463621%40googlegroups.com.

How do I reference individual columns?
 2.3.3 :006 > @item.item_item_properties.item_property_id
NoMethodError: undefined method `item_property_id' for #<ItemItemProperty::ActiveRecord_Associations_CollectionProxy:0x0055d4167fd628>

--
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/a80b3961-82df-4943-9e5a-adb764d516b7%40googlegroups.com.

Could I directly access key, value without pluck or otherwise like
 @item.item_item_properties.each do |key, value|
item_property_id

--
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/b2057f01-80e0-4816-8893-b783e30159f8%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/CAPS3bcCGOC%3DindJPMT0xJGj9EmJ1c7tMLTpP00Vb1nX8wBQuUQ%40mail.gmail.com.

Ruby on Rails



On Thursday, October 31, 2019 at 9:33:22 PM UTC-4, Ariel Juodziukynas wrote:
@item.item_item_properties returns a collection of objects, you are calling a method on something array-like, it makes no sense.

If you want to get all the item_property_ids you can do @item.item_item_properties.pluck(:item_property_id) for example. I'm not sure what you want to achieve.

El jue., 31 oct. 2019 a las 22:29, fugee ohu (<fuge...@gmail.com>) escribió:


On Thursday, October 31, 2019 at 2:15:48 PM UTC-4, Ariel Juodziukynas wrote:
Use `.size` instead of `.count`. "count" does a database query and since you only built the element the COUNT db query will return 0. "size" knows what to do if the association is already initialized so it will return "1" in your case (and if it's not already loaded it will run a COUNT db query).

El jue., 31 oct. 2019 a las 8:42, fugee ohu (<fuge...@gmail.com>) escribió:
> @item=Item.new
> @item.item_item_properties.build
> @item.item_item_properties.count
 => 0

Why doesn't my @item object have any item_item_properties after build method

--
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/161b90ed-b6b1-4d4d-9f67-fb70f0463621%40googlegroups.com.

How do I reference individual columns?
 2.3.3 :006 > @item.item_item_properties.item_property_id
NoMethodError: undefined method `item_property_id' for #<ItemItemProperty::ActiveRecord_Associations_CollectionProxy:0x0055d4167fd628>

--
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/a80b3961-82df-4943-9e5a-adb764d516b7%40googlegroups.com.

Could I directly access key, value without pluck or otherwise like
 @item.item_item_properties.each do |key, value|
item_property_id

--
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/b2057f01-80e0-4816-8893-b783e30159f8%40googlegroups.com.

Ruby on Rails

@item.item_item_properties returns a collection of objects, you are calling a method on something array-like, it makes no sense.

If you want to get all the item_property_ids you can do @item.item_item_properties.pluck(:item_property_id) for example. I'm not sure what you want to achieve.

El jue., 31 oct. 2019 a las 22:29, fugee ohu (<fugee279@gmail.com>) escribió:


On Thursday, October 31, 2019 at 2:15:48 PM UTC-4, Ariel Juodziukynas wrote:
Use `.size` instead of `.count`. "count" does a database query and since you only built the element the COUNT db query will return 0. "size" knows what to do if the association is already initialized so it will return "1" in your case (and if it's not already loaded it will run a COUNT db query).

El jue., 31 oct. 2019 a las 8:42, fugee ohu (<fuge...@gmail.com>) escribió:
> @item=Item.new
> @item.item_item_properties.build
> @item.item_item_properties.count
 => 0

Why doesn't my @item object have any item_item_properties after build method

--
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/161b90ed-b6b1-4d4d-9f67-fb70f0463621%40googlegroups.com.

How do I reference individual columns?
 2.3.3 :006 > @item.item_item_properties.item_property_id
NoMethodError: undefined method `item_property_id' for #<ItemItemProperty::ActiveRecord_Associations_CollectionProxy:0x0055d4167fd628>

--
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/a80b3961-82df-4943-9e5a-adb764d516b7%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/CAPS3bcAxtZ4PK3yFBT9EZ%3DeB241Ub488xyePjQnozOkbXXyo0Q%40mail.gmail.com.

Ruby on Rails



On Thursday, October 31, 2019 at 2:15:48 PM UTC-4, Ariel Juodziukynas wrote:
Use `.size` instead of `.count`. "count" does a database query and since you only built the element the COUNT db query will return 0. "size" knows what to do if the association is already initialized so it will return "1" in your case (and if it's not already loaded it will run a COUNT db query).

El jue., 31 oct. 2019 a las 8:42, fugee ohu (<fuge...@gmail.com>) escribió:
> @item=Item.new
> @item.item_item_properties.build
> @item.item_item_properties.count
 => 0

Why doesn't my @item object have any item_item_properties after build method

--
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/161b90ed-b6b1-4d4d-9f67-fb70f0463621%40googlegroups.com.

How do I reference individual columns?
 2.3.3 :006 > @item.item_item_properties.item_property_id
NoMethodError: undefined method `item_property_id' for #<ItemItemProperty::ActiveRecord_Associations_CollectionProxy:0x0055d4167fd628>

--
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/a80b3961-82df-4943-9e5a-adb764d516b7%40googlegroups.com.

Ruby on Rails



On Thursday, October 31, 2019 at 2:15:48 PM UTC-4, Ariel Juodziukynas wrote:
Use `.size` instead of `.count`. "count" does a database query and since you only built the element the COUNT db query will return 0. "size" knows what to do if the association is already initialized so it will return "1" in your case (and if it's not already loaded it will run a COUNT db query).

El jue., 31 oct. 2019 a las 8:42, fugee ohu (<fuge...@gmail.com>) escribió:
> @item=Item.new
> @item.item_item_properties.build
> @item.item_item_properties.count
 => 0

Why doesn't my @item object have any item_item_properties after build method

--
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/161b90ed-b6b1-4d4d-9f67-fb70f0463621%40googlegroups.com.

How do I reference individual values

--
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/5ec7f561-3926-43bb-9883-0ac7d5f36642%40googlegroups.com.

Ruby on Rails

Use `.size` instead of `.count`. "count" does a database query and since you only built the element the COUNT db query will return 0. "size" knows what to do if the association is already initialized so it will return "1" in your case (and if it's not already loaded it will run a COUNT db query).

El jue., 31 oct. 2019 a las 8:42, fugee ohu (<fugee279@gmail.com>) escribió:
> @item=Item.new
> @item.item_item_properties.build
> @item.item_item_properties.count
 => 0

Why doesn't my @item object have any item_item_properties after build method

--
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/161b90ed-b6b1-4d4d-9f67-fb70f0463621%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/CAPS3bcC%3Djx6MabXASiB2DXgNMeWdw0TMo%2B%3D979RgfHnoN-rH_Q%40mail.gmail.com.

Ruby on Rails

You also might be running into issues regarding transient layers in Docker; it's *really* not expecting you to log in and run a few scripts to install dependencies.

It's expecting you to do that in your Dockerfile. It's entirely possible simplecov or whatever other gem you are using is simply being discarded when the container shuts down. When a container is started, docker creates a transient layer for the container for things like logs, etc. Anything that isn't in a volume will be erased once the container stops running - it doesn't save that transient layer on container exit.

For a first start, what I might try is this: setup everything in one box like you were before, but this time, do it all from the Dockerfile.

I think you might find that you will have a lot more success that way.

On Thu, Oct 31, 2019 at 11:56 AM Walther Diechmann <walther@diechmann.net> wrote:
On the 'running of shells and entering information manually' - I guess that defeats the purpose of Docker (which basically is to allow automation and optimise CPUsage :)

On simplecov - tried to do "gem install simplecov" from that docker shell of yours?

Den 31. okt. 2019 kl. 16.11 skrev Jason Hsu <jhsu802701@gmail.com>:

Thanks, Walther, on the suggestion of adding a docker container specifically dedicated to running tests.  (I personally don't agree with the use of Guard, so I'd just run the shell and then enter the test commands when necessary.)  Why isn't this normally done?

But exactly what is the docker-compose command for running the test suite on Octobox?  Every time I've tried to run the test suite with a docker-compose command, I get stopped in my tracks by an error message telling me that simplecov isn't loading.  For reasons I haven't been able to figure out, the simplecov gem doesn't get installed when I enter "bundle install" even though it's in the Gemfile and Gemfile.lock.  I even tried starting a Docker container to run an sh shell, and running "bundle install" didn't install the simplecov gem.

On Thursday, October 31, 2019 at 6:13:23 AM UTC-5, walt wrote:
IMHO ".., I use just one Docker container" is the first order of (your) business to get straighten out :)

Using containers with Rails is quite a feast - and an added bonus is that once set up you have next to zero footprint on your 'own' computer (that is a blatant lye 'cause your code base needs to sit somewhere, and the docker images has to be in place too - but even that could be 'clouded')

Docker containers doesn't really start to shining until you let them ;)

That is - delegate delegate delegate - or: one container per "task" 

You'll have at least three containers spinning - again IMHO. An app container with the Puma webserver serving the Rails stuff, a database container for the Rails models to persist their data, and a container for a reversed NgINX proxy serving clients on 80/443 and forwarding the necessary requests to the 'animal' (Puma). Other container candidates are: Redis, Sidekiq, and memcached. Here are the observations by Cloud66 - ALCO Spamstop har genkendt svig på hjemmesiden "www.google.com". Du gør klogt i ikke at have tiltro til denne hjemmeside: https://blog.cloud66.com/containers-for-rails-developers-use-containers-while-staying-true-to-your-ror-roots/

Use hub.docker.com to load the necessary images, then use github.com to load the codebase, then 

docker-compose build
docker-compose up (-d if you'd like it to sit in the background=daemonized)

That's it - more or less

Getting there will take you through one/two hoops I know for sure but it's worth the journey!


Chris Blunt did an excellent demonstration job!


--
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/f91bed88-c4fc-4230-91e2-61da850b0c80%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/D3997780-2764-4BB8-A0B8-0234B34D7B91%40diechmann.net.

--
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/CA%2BCQ9365fFPxffRtek5v980CoTivhC9tPk4%2BQmASUvZN-kwO1g%40mail.gmail.com.

Ruby on Rails

On the 'running of shells and entering information manually' - I guess that defeats the purpose of Docker (which basically is to allow automation and optimise CPUsage :)


On simplecov - tried to do "gem install simplecov" from that docker shell of yours?

Den 31. okt. 2019 kl. 16.11 skrev Jason Hsu <jhsu802701@gmail.com>:

Thanks, Walther, on the suggestion of adding a docker container specifically dedicated to running tests.  (I personally don't agree with the use of Guard, so I'd just run the shell and then enter the test commands when necessary.)  Why isn't this normally done?

But exactly what is the docker-compose command for running the test suite on Octobox?  Every time I've tried to run the test suite with a docker-compose command, I get stopped in my tracks by an error message telling me that simplecov isn't loading.  For reasons I haven't been able to figure out, the simplecov gem doesn't get installed when I enter "bundle install" even though it's in the Gemfile and Gemfile.lock.  I even tried starting a Docker container to run an sh shell, and running "bundle install" didn't install the simplecov gem.

On Thursday, October 31, 2019 at 6:13:23 AM UTC-5, walt wrote:
IMHO ".., I use just one Docker container" is the first order of (your) business to get straighten out :)

Using containers with Rails is quite a feast - and an added bonus is that once set up you have next to zero footprint on your 'own' computer (that is a blatant lye 'cause your code base needs to sit somewhere, and the docker images has to be in place too - but even that could be 'clouded')

Docker containers doesn't really start to shining until you let them ;)

That is - delegate delegate delegate - or: one container per "task" 

You'll have at least three containers spinning - again IMHO. An app container with the Puma webserver serving the Rails stuff, a database container for the Rails models to persist their data, and a container for a reversed NgINX proxy serving clients on 80/443 and forwarding the necessary requests to the 'animal' (Puma). Other container candidates are: Redis, Sidekiq, and memcached. Here are the observations by Cloud66 - ALCO Spamstop har genkendt svig på hjemmesiden "www.google.com". Du gør klogt i ikke at have tiltro til denne hjemmeside: https://blog.cloud66.com/containers-for-rails-developers-use-containers-while-staying-true-to-your-ror-roots/

Use hub.docker.com to load the necessary images, then use github.com to load the codebase, then 

docker-compose build
docker-compose up (-d if you'd like it to sit in the background=daemonized)

That's it - more or less

Getting there will take you through one/two hoops I know for sure but it's worth the journey!


Chris Blunt did an excellent demonstration job!


--
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/f91bed88-c4fc-4230-91e2-61da850b0c80%40googlegroups.com.

Ruby on Rails

Thanks, Walther, on the suggestion of adding a docker container specifically dedicated to running tests.  (I personally don't agree with the use of Guard, so I'd just run the shell and then enter the test commands when necessary.)  Why isn't this normally done?

But exactly what is the docker-compose command for running the test suite on Octobox?  Every time I've tried to run the test suite with a docker-compose command, I get stopped in my tracks by an error message telling me that simplecov isn't loading.  For reasons I haven't been able to figure out, the simplecov gem doesn't get installed when I enter "bundle install" even though it's in the Gemfile and Gemfile.lock.  I even tried starting a Docker container to run an sh shell, and running "bundle install" didn't install the simplecov gem.

On Thursday, October 31, 2019 at 6:13:23 AM UTC-5, walt wrote:
IMHO ".., I use just one Docker container" is the first order of (your) business to get straighten out :)

Using containers with Rails is quite a feast - and an added bonus is that once set up you have next to zero footprint on your 'own' computer (that is a blatant lye 'cause your code base needs to sit somewhere, and the docker images has to be in place too - but even that could be 'clouded')

Docker containers doesn't really start to shining until you let them ;)

That is - delegate delegate delegate - or: one container per "task" 

You'll have at least three containers spinning - again IMHO. An app container with the Puma webserver serving the Rails stuff, a database container for the Rails models to persist their data, and a container for a reversed NgINX proxy serving clients on 80/443 and forwarding the necessary requests to the 'animal' (Puma). Other container candidates are: Redis, Sidekiq, and memcached. Here are the observations by Cloud66 - https://blog.cloud66.com/containers-for-rails-developers-use-containers-while-staying-true-to-your-ror-roots/

Use hub.docker.com to load the necessary images, then use github.com to load the codebase, then 

docker-compose build
docker-compose up (-d if you'd like it to sit in the background=daemonized)

That's it - more or less

Getting there will take you through one/two hoops I know for sure but it's worth the journey!


Chris Blunt did an excellent demonstration job!

--
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/f91bed88-c4fc-4230-91e2-61da850b0c80%40googlegroups.com.

Ruby on Rails

> @item=Item.new
> @item.item_item_properties.build
> @item.item_item_properties.count
 => 0

Why doesn't my @item object have any item_item_properties after build method

--
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/161b90ed-b6b1-4d4d-9f67-fb70f0463621%40googlegroups.com.

Ruby on Rails

IMHO ".., I use just one Docker container" is the first order of (your) business to get straighten out :)


Using containers with Rails is quite a feast - and an added bonus is that once set up you have next to zero footprint on your 'own' computer (that is a blatant lye 'cause your code base needs to sit somewhere, and the docker images has to be in place too - but even that could be 'clouded')

Docker containers doesn't really start to shining until you let them ;)

That is - delegate delegate delegate - or: one container per "task" 

You'll have at least three containers spinning - again IMHO. An app container with the Puma webserver serving the Rails stuff, a database container for the Rails models to persist their data, and a container for a reversed NgINX proxy serving clients on 80/443 and forwarding the necessary requests to the 'animal' (Puma). Other container candidates are: Redis, Sidekiq, and memcached. Here are the observations by Cloud66 - https://blog.cloud66.com/containers-for-rails-developers-use-containers-while-staying-true-to-your-ror-roots/

Use hub.docker.com to load the necessary images, then use github.com to load the codebase, then 

docker-compose build
docker-compose up (-d if you'd like it to sit in the background=daemonized)

That's it - more or less

Getting there will take you through one/two hoops I know for sure but it's worth the journey!


Chris Blunt did an excellent demonstration job!


Cheers,
Walther

Den 30. okt. 2019 kl. 18.08 skrev Jason Hsu <jhsu802701@gmail.com>:

Yes.  However, I use just one Docker container that contains everything I need, including Ruby, Rails, Node.js, PostgreSQL, Redis, etc.  I know that my way is crude, but it works.  I can't move on to the docker-compose way of doing things until I figure out all the issues that are stopping me.

On Wednesday, October 30, 2019 at 11:07:06 AM UTC-5, Brandon McClelland wrote:
You said "When I log into my custom Docker container, I basically follow the same procedure that the people who rely on their host environments do." Can you run the tests successfully that way?



--
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/5a60f0c7-2dfe-4b03-8a71-679901587b59%40googlegroups.com.

Ruby on Rails Wednesday, October 30, 2019

Yes.  However, I use just one Docker container that contains everything I need, including Ruby, Rails, Node.js, PostgreSQL, Redis, etc.  I know that my way is crude, but it works.  I can't move on to the docker-compose way of doing things until I figure out all the issues that are stopping me.

On Wednesday, October 30, 2019 at 11:07:06 AM UTC-5, Brandon McClelland wrote:
You said "When I log into my custom Docker container, I basically follow the same procedure that the people who rely on their host environments do." Can you run the tests successfully that way?


--
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/5a60f0c7-2dfe-4b03-8a71-679901587b59%40googlegroups.com.

Ruby on Rails

Basically the command after `docker-compose run {{container_name}}` is the exact same command you would enter right after logging into the container.

So if you would log into the container and run "bundle exec rake test", and assuming your container is `app`, you would run:

`docker-compose run web bundle exec rake test`

This is, of course, assuming that you can run tests in the container already.



On Wed, Oct 30, 2019 at 12:06 PM Brandon McClelland <brandon@sjgames.com> wrote:
You said "When I log into my custom Docker container, I basically follow the same procedure that the people who rely on their host environments do." Can you run the tests successfully that way?

On Wed, Oct 30, 2019 at 10:58 AM Jason Hsu <jhsu802701@gmail.com> wrote:
I thought that would work, but simplecov isn't loading.


On Wednesday, October 30, 2019 at 10:53:06 AM UTC-5, Brandon McClelland wrote:
You would do something like this (found at https://blog.codeship.com/testing-rails-application-docker/ after googling "running rails test with docker-compose run"):

docker-compose run -e "RAILS_ENV=test" app rake test

--
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/7bbfbc49-cf34-41ee-9f4b-f9415e631c44%40googlegroups.com.


--
Brandon McClelland
User Support Technician
Steve Jackson Games

--
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/CADuEqHJJaRdzuV9ce5kAhPxsZfm99xS2KfZSaOwc%2Bk03xVyfXQ%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/CA%2BCQ936yZ%3DeFSfeRDg69P66QvT2cOjP2RO8HUs%3DddDwAOrOQPA%40mail.gmail.com.

Ruby on Rails

You said "When I log into my custom Docker container, I basically follow the same procedure that the people who rely on their host environments do." Can you run the tests successfully that way?

On Wed, Oct 30, 2019 at 10:58 AM Jason Hsu <jhsu802701@gmail.com> wrote:
I thought that would work, but simplecov isn't loading.


On Wednesday, October 30, 2019 at 10:53:06 AM UTC-5, Brandon McClelland wrote:
You would do something like this (found at https://blog.codeship.com/testing-rails-application-docker/ after googling "running rails test with docker-compose run"):

docker-compose run -e "RAILS_ENV=test" app rake test

--
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/7bbfbc49-cf34-41ee-9f4b-f9415e631c44%40googlegroups.com.


--
Brandon McClelland
User Support Technician
Steve Jackson Games

--
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/CADuEqHJJaRdzuV9ce5kAhPxsZfm99xS2KfZSaOwc%2Bk03xVyfXQ%40mail.gmail.com.

Ruby on Rails

I thought that would work, but simplecov isn't loading.


On Wednesday, October 30, 2019 at 10:53:06 AM UTC-5, Brandon McClelland wrote:
You would do something like this (found at https://blog.codeship.com/testing-rails-application-docker/ after googling "running rails test with docker-compose run"):

docker-compose run -e "RAILS_ENV=test" app rake test

--
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/7bbfbc49-cf34-41ee-9f4b-f9415e631c44%40googlegroups.com.

Ruby on Rails

You would do something like this (found at https://blog.codeship.com/testing-rails-application-docker/ after googling "running rails test with docker-compose run"):

docker-compose run -e "RAILS_ENV=test" app rake test

On Wed, Oct 30, 2019 at 9:53 AM San Ji <sarun101@gmail.com> wrote:
Sad, indeed

--
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/66aab950-9d5c-41a5-bec0-e88407b73675%40googlegroups.com.


--
Brandon McClelland
User Support Technician
Steve Jackson Games

--
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/CADuEqHLPYVe4pwgJ%3Dcrg8TUWu9TOR-XS8Cw0h9yV4u-wGHvW9Q%40mail.gmail.com.

Ruby on Rails

Sad, indeed

--
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/66aab950-9d5c-41a5-bec0-e88407b73675%40googlegroups.com.

Ruby on Rails

What's the full command for running the test suite?  Sadly, but this isn't a CS class that one can BS through with partial credit.

On Wednesday, October 30, 2019 at 7:25:06 AM UTC-5, San Ji wrote:
docker-compose run?

https://docs.docker.com/compose/reference/run/

--
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/9d2fcfc0-b32b-4008-87ea-61e64212fbed%40googlegroups.com.

Ruby on Rails

docker-compose run?

https://docs.docker.com/compose/reference/run/

--
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/495bfc30-aef0-4f86-aff2-392873fc9db6%40googlegroups.com.

Ruby on Rails Tuesday, October 29, 2019

I've contributed to the Octobox app (https://github.com/octobox/octobox).  I've been using a weird system of using Docker.  Instead of using it the normal way, I create my own custom Docker image for each Rails project that I'm on.  When I log into my custom Docker container, I basically follow the same procedure that the people who rely on their host environments do.

I'm trying to learn the more conventional way of using Docker with docker-compose, but I'm having difficulty finding out how you're supposed to run the test suite.

I've followed the instructions at https://github.com/octobox/octobox/blob/master/docs/INSTALLATION.md#using-docker-and-docker-compose .  While I've been able to get the development environment working, I have not been able to figure out how I'm supposed to run the test suite with the docker-compose command.  Exactly what is the command for running the test suite?

--
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/4acb9ce6-c5d3-4056-99b0-6e21c704ff03%40googlegroups.com.