hnanon

Activity Graph

Page 1 of 19 | Next »

2019-01-16

[00:10:47] hnanon: has joined #RubyOnRails
[00:11:44] hnanon: Is it a good idea to sprinkle Rails.logger.info messages within ifs and elses?
[00:11:59] hnanon: (specifically, within a job)
[01:40:17] hnanon: Ping timeout: 256 seconds

2019-01-10

[12:51:43] hnanon: has joined #RubyOnRails
[12:57:44] hnanon: I have this piece of code: https://dpaste.de/G9Oy
[12:58:10] hnanon: How can I get the actual index number in the params, instead of ":index"?
[12:59:38] hnanon: Instead of {:index=>{:invoiceable_type=>"Subscription", :invoiceable_id=>4,...
[13:00:11] hnanon: Something like {"0"=>{:invoiceable_type=>"Subscription", :invoiceable_id=>4,...
[13:03:42] hnanon: This works: { index => { "invoiceable_type": "Subscription", "invoiceable_id": subscription_id...
[13:07:08] hnanon: Quit: Page closed

2018-12-31

[08:54:59] hnanon: has joined #RubyOnRails
[08:55:48] hnanon: I have a question about how fast records get created in a db...
[08:56:11] hnanon: For example, I'm using the Twilio API to create call records...
[08:56:24] hnanon: When a call is answered, a Call record is created.
[08:56:48] hnanon: After the call, Twilio posts to a callback URL with a link of the call recording...
[08:57:19] hnanon: I want to update the call record with that URL.
[08:57:40] hnanon: Can I be sure that the call record will be created in time to find it for the update?
[10:27:15] hnanon: Quit: Page closed

2018-12-28

[11:45:02] hnanon: has joined #RubyOnRails
[11:45:56] hnanon: Can I do this...
[11:46:00] hnanon: @subscription.forwarding_number_lookup(@subscription.forwarding_numbers.first)
[11:46:11] hnanon: in my Subscriptions create action?
[11:47:20] hnanon: In my Subscription model I have def forwarding_number_lookup(forwarding_number)
[11:47:29] hnanon: but I get the following error:
[11:49:02] hnanon: wrong number of arguments (given 0, expected 1)
[11:49:27] hnanon: pointing to this line: def forwarding_number_lookup(forwarding_number)
[11:50:11] hnanon: But the argument is right there.
[11:53:22] hnanon: validate :forwarding_number_lookup
[11:53:36] hnanon: That's a custom validation if that matters.
[12:16:36] hnanon: I guess my question is can I pass a nested object as an argument?
[12:18:43] hnanon: I think the problem is because the object is not persisted yet?
[12:32:09] hnanon: Ping timeout: 256 seconds

2018-12-13

[00:54:53] hnanon: has joined #RubyOnRails
[00:56:41] hnanon: If I have an array: ["1234", "1123", "2345"], how can I get "1123", the value that has two consecutive identical values?
[00:57:09] hnanon: identical characters or digits, I should say.
[01:05:27] hnanon: Radar: Let me see...
[01:09:52] hnanon: Radar: each_cons is cool.
[01:10:49] hnanon: Radar: While I have you here, do you agree with this: https://medium.com/planet-arkency/the-biggest-rails-code-smell-you-should-avoid-to-keep-your-app-healthy-a61fd75ab2d3
[02:00:50] hnanon: Radar, what about this comment: https://medium.com/@vemv/if-you-care-about-transactionality-you-cannot-beat-after-commit-in-particular-38a742efbeb3
[02:07:01] hnanon: sevenseacat: That's how I tend view it, personally.
[02:09:04] hnanon: Hmm...it's a little bothersome that the "Rails Way" is not necessarily the best way, at least in the opinion of you two.
[02:10:08] hnanon: Radar: I know. But I'm sure you two have your opinions for good reasons.
[02:10:55] hnanon: One would think there would at least some general consensus, at least about the major features of Rails.
[02:12:00] hnanon: Radar: What about the idea that Rails is the way it is because it's battle-tested by Basecamp?
[02:12:36] hnanon: They had problems and DHH shaped Rails to solve those problems.
[02:13:07] hnanon: Like including ActiveStorage, for example.
[03:05:17] hnanon: Ping timeout: 256 seconds

2018-12-11

[05:59:05] hnanon: has joined #RubyOnRails
[06:00:15] hnanon: I have a nested form. My subscriptions controller has @subscription.notifications.build
[06:00:35] hnanon: There will only be two notifications.
[06:00:55] hnanon: The first will be for calls. The second will be for emails.
[06:01:32] hnanon: It's working fine, as is. However, I want to add a short description of for each notification field.
[06:01:41] hnanon: How can I do that?
[06:02:14] hnanon: When I add both nested fields manually, I get duplicate fields.
[06:07:36] hnanon: When I try the following, the second field value (email) overwrites the first (phone number):
[06:07:37] hnanon: https://dpaste.de/wvOM
[06:08:08] hnanon: In that case, both fields' name value is subscription[notifications_attributes][0][value]
[06:15:45] hnanon: I got it working.
[06:16:02] hnanon: I ended up putting the second field in a second <%= form.fields_for :notifications do |notification| %>
[06:55:09] hnanon: Quit: Page closed

2018-11-23

[07:20:37] hnanon: Remote host closed the connection
[07:20:57] hnanon: has joined #RubyOnRails
[07:22:07] hnanon: Read error: Connection reset by peer
[07:22:28] hnanon: has joined #RubyOnRails
[18:09:16] hnanon: Ping timeout: 260 seconds

2018-11-22

[00:49:47] hnanon: Ping timeout: 276 seconds
[05:14:57] hnanon: has joined #RubyOnRails
[06:52:36] hnanon: I want to add a Facebook pixel to the show view of an order, upon order completion. This same show page (with a unique, hard-to-guess slug as the route param is also where the customer goes to check their order status.
[06:52:54] hnanon: I don't want the facebook pixel to trigger every time they check their order status.
[06:54:14] hnanon: Should I just show the pixel if the created_at attribute is > Time.now - 5 seconds or so?
[10:43:53] hnanon: Ping timeout: 250 seconds
[19:57:08] hnanon: has joined #RubyOnRails
[21:50:06] hnanon: Ping timeout: 260 seconds
[23:08:24] hnanon: has joined #RubyOnRails

2018-11-21

[00:39:38] hnanon: Ping timeout: 276 seconds
[02:22:45] hnanon: has joined #RubyOnRails
[05:35:57] hnanon: Read error: Connection reset by peer
[05:36:22] hnanon: has joined #RubyOnRails
[07:48:22] hnanon: Ping timeout: 250 seconds
[14:53:44] hnanon: has joined #RubyOnRails
[16:18:12] hnanon: Ping timeout: 252 seconds
[16:27:58] hnanon: has joined #RubyOnRails
[17:38:02] hnanon: Ping timeout: 250 seconds
[23:19:40] hnanon: has joined #RubyOnRails

2018-11-20

[03:26:00] hnanon: has joined #RubyOnRails
[08:05:28] hnanon: Ping timeout: 264 seconds
[14:15:10] hnanon: has joined #RubyOnRails
[14:50:11] hnanon: Ping timeout: 260 seconds
[16:35:16] hnanon: has joined #RubyOnRails
[20:01:42] hnanon: Ping timeout: 244 seconds
[20:51:53] hnanon: has joined #RubyOnRails
[20:52:23] hnanon: Read error: Connection reset by peer
[20:53:05] hnanon: has joined #RubyOnRails
[22:25:53] hnanon: Ping timeout: 245 seconds
[22:32:59] hnanon: has joined #RubyOnRails
[23:32:38] hnanon: Can I update nested attributes in an action before saving the parent?
[23:32:58] hnanon: Or, assign attributes, actually (not update).

2018-11-19

[02:08:19] hnanon: Ping timeout: 250 seconds

2018-11-18

[16:34:47] hnanon: has joined #RubyOnRails
[17:02:44] hnanon: Is the answer give here a good approach:
[17:02:46] hnanon: https://stackoverflow.com/questions/40931906/rails-are-saving-params-in-sessions-a-generally-good-idea-for-multistep-forms
[17:58:36] hnanon: Ping timeout: 250 seconds
[18:36:50] hnanon: has joined #RubyOnRails
[19:30:04] hnanon: Ping timeout: 264 seconds
[20:13:03] hnanon: has joined #RubyOnRails

2018-11-16

[00:41:47] hnanon: has joined #RubyOnRails
[00:57:36] hnanon: I'm wondering if I should create a FulfillmentStatus model to track order status: received, processed, shipped, delivered.
[00:58:13] hnanon: And the same for PaymentStatus: paid, refunded
[00:58:59] hnanon: Or, just overwrite a status attributes on the Order model: fulfillment_status, payment_status
[01:05:38] hnanon: mlt-: Yeah, I was just thinking it would be cool to show a little table to customers of how the order is progressing.
[01:20:03] hnanon: If I have item_total, tax_total, and shipping_total attributes, is it a good practice to also have an order_total that sums them all. Or, should I just do that in the view?
[02:19:15] hnanon: Ping timeout: 256 seconds

2018-11-15

[02:18:23] hnanon: has joined #RubyOnRails
[04:29:52] hnanon: Is there a way to access the last param hash of a nested attribute?
[04:31:42] hnanon: https://dpaste.de/KswP
[04:32:14] hnanon: In that instance it's images_attributes 1
[04:32:38] hnanon: It'll be different for other variants.
[04:32:51] hnanon: I want to always get the last images_attributes.
[04:33:02] hnanon: That's the one that will have the file.
[04:33:16] hnanon: (to attach via active_storage)
[04:33:35] hnanon: I probably won
[04:33:46] hnanon: won't end up doing it this way...
[04:34:00] hnanon: but I'm just curious how that would be done.
[04:34:35] hnanon: Radar: Yup, that's what I'll probably do.
[04:35:27] hnanon: Your solution seems perfect, though, if I do end up keeping the nested attributes.
[04:36:24] hnanon: Radar: Did Spree create a default variant when a product was created?
[04:37:00] hnanon: I think variants should be be added to carts and products...from what I gather so far.
[04:37:16] hnanon: *added to cart, not products
[04:37:52] hnanon: The master variant was created in an after action?
[04:57:14] hnanon: Radar, can I just use the .dig method too (too look for the file key)?
[04:58:06] hnanon: Yes, it's an array
[04:58:10] hnanon: I mean a hash
[07:43:29] hnanon: Ping timeout: 256 seconds

2018-11-14

[00:47:59] hnanon: has joined #RubyOnRails
[00:50:14] hnanon: I have a CollectionProduct join model between Collection and Product models.
[00:50:57] hnanon: Within an admin namespace (/admin/products/1/) I have the line: <%= link_to 'Remove', @product.collections.destroy(collection), method: :delete, data: { confirm: 'Are you sure?' } %>
[00:51:33] hnanon: When I go to that page, the actual collection is destroyed (without clicking the link!).
[00:51:56] hnanon: How can I just destroy the record within the joins table?
[00:52:54] hnanon: In other words, just visiting the page calls the destroy method.
[00:55:25] hnanon: Which controller should the destroy action be in?
[00:55:31] hnanon: Products?
[00:56:04] hnanon: Yes, exactly.
[00:58:50] hnanon: What about using creating and using a collection_products controller?
[00:59:07] hnanon: *creating and using
[01:04:43] hnanon: Can I pass two arguments to its named path...something like: admin_collection_products_path(@product, collection)?
[01:09:42] hnanon: It looks like I can pass params to the path.
[01:10:57] hnanon: So, something like admin_collection_product_path(product: @product, collection: collection).
[01:11:17] hnanon: Then I can access those params like normal in the destroy action.
[01:11:42] hnanon: Or, is that convoluted and I'm overthinking it?
[02:38:13] hnanon: Remote host closed the connection
[02:38:42] hnanon: has joined #RubyOnRails
[04:23:12] hnanon: Remote host closed the connection
[04:23:39] hnanon: has joined #RubyOnRails
[04:24:42] hnanon: Remote host closed the connection
[04:25:10] hnanon: has joined #RubyOnRails
[04:27:12] hnanon: Remote host closed the connection
[04:27:40] hnanon: has joined #RubyOnRails
[07:02:28] hnanon: Ping timeout: 264 seconds

2018-11-13

[01:27:30] hnanon: Hey Radar.
[01:29:23] hnanon: Am I remembering that correctly?
[01:29:23] hnanon: I remember, years ago, you said something about shopping carts and orders being basically the same, just in different states...or something like that.
[01:42:56] hnanon: Yeah, really.
[01:43:34] hnanon: Your opinion is different now?
[01:44:59] hnanon: I see. Cool. I'm working on an ecommerce app at the moment.
[02:03:46] hnanon: Ping timeout: 244 seconds
[05:00:15] hnanon: has joined #RubyOnRails
[05:04:42] hnanon: Ping timeout: 252 seconds
[14:19:33] hnanon: has joined #RubyOnRails
[15:07:06] hnanon: Ping timeout: 260 seconds
[15:13:19] hnanon: has joined #RubyOnRails
[15:25:35] hnanon: Quit: Leaving
[23:23:39] hnanon: has joined #RubyOnRails
[23:41:09] hnanon: Ping timeout: 250 seconds

2018-11-12

[17:18:59] hnanon: has joined #RubyOnRails
[17:24:49] hnanon: I have this line in a VariantOption model: attribute :option_name
[17:25:01] hnanon: It's using the new 5.2 attributes api.
[17:25:44] hnanon: In my Variants controller I have @options.each { |name, id| @variant.variant_options.build(option_name: name, option_id: id) }
[17:26:10] hnanon: So, with that, I'm assuming I should be able to access the option name with :option_name.
[17:26:37] hnanon: However, when I do:
[17:26:55] hnanon: <%= variant_option.text_field :value, placeholder: :option_name %>
[17:27:17] hnanon: The placeholder text is only "Option name," without the the actual name of the option.
[17:27:21] hnanon: Any ideas?
[17:28:57] hnanon: :option_id does indeed show the actual option id.
[17:29:31] hnanon: Why does :option_name not show the option name?
[17:31:09] hnanon: Doing @options.each { |name, id| puts name+id.to_s } does print both the name and id so I know that name is present.
[17:58:28] hnanon: Finally, after all last night and this morning...I had to do: placeholder: variant_option.object.option_name
[17:58:38] hnanon: That "object" was key.
[17:58:54] hnanon: Is that documented anywhere (the use of "object").
[18:30:26] hnanon: Ping timeout: 260 seconds
[19:52:08] hnanon: has joined #RubyOnRails
[21:27:34] hnanon: Ping timeout: 246 seconds
[23:41:36] hnanon: has joined #RubyOnRails

2018-11-10

[02:07:08] hnanon: has joined #RubyOnRails
[03:32:36] hnanon: Ping timeout: 252 seconds
[03:45:41] hnanon: has joined #RubyOnRails
[05:24:15] hnanon: Ping timeout: 252 seconds

2018-11-09

[00:52:39] hnanon: Read error: Connection reset by peer
[16:45:36] hnanon: has joined #RubyOnRails
[16:46:13] hnanon: Should timestamps be stored as integers or datetime?
[16:46:44] hnanon: Is there a preference or convention (besides the created_at and updated_at attributes)
[16:53:08] hnanon: crankharder, They're datetimes for created_at and updated_at.
[16:53:42] hnanon: I'm using Stripe and one of their data fields is a timestamp as an integerr.
[16:54:02] hnanon: I wasn't sure if I should convert it or just keep in their native version.
[17:35:48] hnanon: Ping timeout: 272 seconds
[19:39:10] hnanon: has joined #RubyOnRails
[20:07:41] hnanon: Read error: Connection reset by peer
[20:08:10] hnanon: has joined #RubyOnRails
[22:29:36] hnanon: Read error: Connection reset by peer

2018-11-08

[22:46:23] hnanon: has joined #RubyOnRails
[22:47:24] hnanon: Is it normal for nested fields to be duplicated on a create (validation) error?
[22:48:33] hnanon: New action has @subscription.notifications.build
[22:50:12] hnanon: Nevermind. It's always a silly mistake.
[22:50:27] hnanon: I was calling fields_for twice in the form.

2018-08-08

[19:46:54] hnanon: has joined #RubyOnRails
[19:48:51] hnanon: I have a User model with a profile image attachment, attached via Paperclip. I newly create a Profile model and it now will have that image as an attribute (instead of the User having it). I also migrated to ActiveStorage.
[19:48:58] hnanon: New attachments work fine.
[19:49:19] hnanon: How can I migrate the older referenced images from the User table to the Profile table?
[19:49:52] hnanon: I'm trying to follow this guide: https://github.com/thoughtbot/paperclip/blob/master/MIGRATING.md
[19:50:16] hnanon: However, that just migrates from the User table to the same User table.
[19:50:36] hnanon: I'm not sure how to adopt it to migrate to the Profile model.
[20:10:10] hnanon: Inside: from PC to AS.
[21:40:30] hnanon: Ping timeout: 252 seconds

2018-07-17

[21:48:29] hnanon: has joined #RubyOnRails
[21:50:50] hnanon: If I have a has_one relationship...let's say Book has_one Author...after the Author is created and associated with a Book, what happens when I recreate an Author for the same Book? Does it just update the existing Author? If not, shouldn't it?
[21:51:55] hnanon: Or, does a new Author get created with same Book association as the existing, first Author?
[21:52:45] hnanon: If the latter is the case, how does rails know which author to use for the Book's has_one relationship?
[21:53:15] hnanon: I'm asking because, for ActiveStorage, the attachment is updated in that case, and not created.
[21:53:24] hnanon: *not recreated
[21:57:35] hnanon: So, a new object is in fact recreated when there is an existing has_one association.
[21:58:30] hnanon: Additionally, rails uses the first object. So, Book.last.author returns the first author, for example.
[21:58:37] hnanon: Is that how it should be?
[22:51:27] hnanon: Ping timeout: 252 seconds

2018-06-20

[19:37:41] hnanon: Quit: Page closed