#RubyOnRails - 08 April 2019
« Back 1 day Forward 1 day »
[06:22:36] shortCircuit__: I am having a problem while writing spec for a method that has a method that accepts a block.
[06:22:53] shortCircuit__: https://gist.github.com/ikouchiha47/fffdfd491a8df4212db0f1824df29762 this is the gist
[06:23:18] shortCircuit__: but if I comment out the particular lines in the code, rspec seems to run successfully
[06:50:27] DaniG2k: I think I somehow need to add the webpacker step to my circleci config file but really not sure how/where
[06:51:01] DaniG2k: the error I'm seeing in CircleCI is: ActionView::Template::Error: Webpacker can't find application in /home/circleci/octopi/public/packs-test/manifest.json. Possible causes:
[07:02:44] DaniG2k: sevenseacat: my webpacker.yml file already seems tobe configured with a production block
[07:20:58] ht85: Hey! I'm working on an app that stores users time zones as friendly names (e.g. "Pacific Time (US & Canada)"), and I'd like to switch to storing the standard name (e.g. "America/Los Angeles"). I've changed it manually and it seems to work, but I'm worried it'll break something.
[07:21:33] ht85: Anyone has experience with this? Is it common to work with regular names as well, or might some gems expect friendly names and break?
[12:34:02] mfoo: Unicorn's documentation for HUP handling states that it "gracefully restarts all workers" - it seems to actually pause requests, then restart all workers at the same time. The effect is that requests hang (connections don't drop). Is there a minimum pool size such that there are always some available workers?
[12:36:50] mfoo: (note that Puma's documentation for USR1 specifies "restart workers in phases, a rolling restart" a number which I assume can be configured but can't find the config for yet
[12:49:45] beilabs: Have an app on 22.214.171.124; all of a sudden our static assets are no longer available on rspec. Any ideas? config.serve_static_files = true in test.rb
[14:13:00] linucks: Hi there, I'm wondering if anyone has experience with asset-sync and AWS for storing static files. I am getting an error "[fog][WARNING] Unable to fetch credentials: connect_write timeout reached" when running bundle exec rake assets:precompile and just cannot work out the cause.
[17:19:47] pitastrudl: im learning rails and i'm wondering what is the purpouse of the asteriks and & symbols in terms of syntax in the database.yml
[17:23:51] pitastrudl: the reason for the question is that on a rake db:create:all, it creates the test database but not the development one, the trace does not say much
[17:39:09] snk: https://stackoverflow.com/questions/41063361/what-is-the-double-left-arrow-syntax-in-yaml-called-and-wheres-it-specced
[17:43:00] nacsurte: is it possible to nil out the foreign key when you delete a belongs_to association?
[17:45:49] Momentum: is it possible to set postgres role in rails? it always default to the current user
[19:25:23] samort7: Can anyone explain to me what the array here does? <%= form_with(model: [ @series, @series.books.build ], local: true) do |form| %>
[20:47:54] snk: samort7: i believe that's needed when you want to reference something in a namespaced route
[20:48:03] snk: see the examples at: https://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-form_with
[20:49:09] samort7: @snk, yea, I have been reading that over-and-over but it's just not clicking for me. I think the issue is what I'm trying to currently do with it
[20:50:29] samort7: I have a series model that has_many book models. All I want is that when you click on the "edit" button for a book inside a series, it pre-populates the fields in the form with the book's data
[20:50:30] snk: yeah, the invocation you gave there is a bit odd. I'd expect something more like `@series, books.new` in order to add a new book to your series model, given what the docs say
[20:51:42] samort7: Here's the actual code. I just started this project so it's really really really basic right now: https://github.com/tliss/lianhuanhua/blob/master/app/views/books/_form.html.erb
[20:52:20] samort7: Also, I should mention that I took that invocation straight from the Rails "Getting Started" guide: https://guides.rubyonrails.org/getting_started.html
[20:52:59] samort7: Where they use <%= form_with(model: [ @article, @article.comments.build ], local: true) do |form| %>
[20:55:06] snk: ah, that's just setting up the form to post to the nested url correctly, it's not doing any autofilling
[20:57:32] snk: provided your series model has a number method to retrieve the number, and it's defined when you render the view
[20:59:44] samort7: If that's the case, then I don't understand why when I click edit for "series", it prepopulates the fields correctly from the database without anything extra added to the form. (referring to this: https://github.com/tliss/lianhuanhua/blob/master/app/views/series/_form.html.erb)
[20:59:46] snk: so, your code is configuring the form to post to `/series/<id>/books`, which may be correct
[21:06:02] samort7: sure, your help is much-appreciated. I've been working on this bug for like 3 days now haha
[21:06:49] samort7: I'm thinking - in my model I retrieve the @series object and the @book object (from that @series object), so I think I should be able to just do mode: @book and have it pre-populate
[21:06:53] snk: but my suspicion is that there's some rails magic for prepopulating simple forms, when you're modifying a simple model -- and the magic doesn't extend to filling form fields for other dependent models
[21:07:40] samort7: snk: But I couldn't find any documentation on it - at least not with form_with. There's a lot of stuff on form_for though
[21:12:11] samort7: It prepopulates when you get to the edit page, but if you try to go to the series/show page it breaks
[21:13:05] samort7: Probably because that page also contains the form, but doesn't have a direct book to reference
[21:23:18] rtrain300: Hi all. I'm getting a "We're sorry, but something went wrong." Error on my application but the server is not outputting any logs. Anyone have ideas?
[21:38:18] snk: but, i think this form really wants to be a @book form, and the series show view needs to know about books
[22:46:08] azta: the time/date helper functions aren't using my timezone, Date.today => Tue, 09 Apr 2019, 1.day.ago => Sun, 07 Apr 2019 22:44:25 UTC +00:00
[22:46:37] azta: Time.now => 2019-04-09 00:44:20 +0200 is correct. Do I need to set this specifically for rails?