LiamW

Activity Graph

Page 1 of 3 | Next »

2019-07-23

[21:46:53] LiamW: has joined #RubyOnRails
[21:47:00] LiamW: https://gist.github.com/liamwhite/4b5a3d51ef92153af87b50daedd2ef4b should I expect this?
[21:48:54] LiamW: sorry I am bad at communication
[21:49:02] LiamW: if you run this inline application the test fails
[21:49:25] LiamW: because a nested attribute, as part of a callback chain, is not being created
[21:49:32] LiamW: even though the creation is succesful

2019-07-13

[00:56:36] LiamW: has joined #RubyOnRails
[00:57:07] LiamW: is it expected behavior that if you redirect and then return false from a before_action callback, that rails will just return an empty page and close the connection?
[01:20:01] LiamW: never mind
[01:20:03] LiamW: has left #RubyOnRails: ("WeeChat 2.3")

2019-07-12

[20:13:47] LiamW: eddybeddy: the answer probably lies more in how you configure your routes than how you split up services
[20:14:26] LiamW: http://jeromedalbert.com/how-dhh-organizes-his-rails-controllers/
[20:16:42] LiamW: cron can eat your command lines
[20:16:54] LiamW: try putting the full invocation in a bash script on the filesystem
[20:16:59] LiamW: then call the script
[20:17:13] LiamW: (e.g. in ~/bin)
[20:51:34] LiamW: has left #RubyOnRails: ("WeeChat 2.3")

2019-07-11

[22:18:50] LiamW: has joined #RubyOnRails
[22:19:39] LiamW: I have a form_for [@user, @award] which I would like to have post create at profile_badge_awards_path and put update at profile_badge_award_path
[22:20:02] LiamW: however, rails wants to submit it to users_badge_awards_path and users_badge_award_path
[22:20:04] LiamW: how do I change this?
[22:26:18] LiamW: it doesn't work for both post create and put update
[22:26:26] LiamW: it only works for one at at time
[22:26:37] LiamW: and I was hoping there was a nicer way than to add a ternary in the conditions
[22:28:27] LiamW: the point of using form_for is that you can stick it in the _form partial for your resource and then use it from both the new and edit actions
[22:28:31] LiamW: this does NOT work if you want to do that
[22:28:54] LiamW: it works for ONE of them
[22:29:18] LiamW: it'll work for the new action if you specify url: :profile_badge_awards
[22:29:29] LiamW: it'll work for the edit action if you specify url: :profile_badge_award
[22:29:46] LiamW: it does not work for both at the same time
[22:29:51] LiamW: which is why I asked
[22:31:31] LiamW: that won't work either
[22:31:47] LiamW: profile_badge_award_path(@user, @award) will not work if @award is a new record
[22:31:57] LiamW: because it doesn't have the id information to key the route
[22:34:12] LiamW: @user.profile isn't a relation
[22:35:43] LiamW: that won't key the route correctly either unless I do something like link it to a User and override to_param
[22:48:08] LiamW: I'm just going to use the ternary for now

2019-07-04

[12:44:06] LiamW: has joined #RubyOnRails
[12:44:53] LiamW: is there a better way to access the join table of a habtm relationship than using reflect_on_association
[12:47:00] LiamW: my join table doesn't have any extra attributes besides the association ids, I just need to alias one side of the relationship into another and don't want to drop to sql just yet if I can avoid it
[12:47:17] LiamW: would like to use upsert_all here
[12:57:18] LiamW: I found classes like this in objectspace User::HABTM_WatchedTags
[12:57:24] LiamW: but cannot seem to access them
[13:05:11] LiamW: apparently it's a private_constant
[13:05:13] LiamW: argh, why
[13:05:52] LiamW: because I don't want to load every single association model into memory?
[13:05:55] LiamW: I just want to do a bulk insert
[13:06:36] LiamW: insert into user_tag_watches select user_id, #{target_tag.id} from user_tag_watches on conflict do nothing;
[13:06:46] LiamW: equivalent to that
[13:07:46] LiamW: I already monkeypatched ActiveRecord::Base to actually allow you to do insert into ... select ... in the first place because that wasn't there at all before
[13:07:58] LiamW: yeah I tried that
[13:08:15] LiamW: what I ended up with was a ton of duplicate associations being returned out of the association
[13:08:34] LiamW: duplicate rows, rather
[13:08:55] LiamW: which should be impossible, because I have a composite unique constraint on the join table
[13:09:04] LiamW: but somehow activerecord managed to do it
[13:09:22] LiamW: it turned 15 rows into 225 rows
[13:09:58] LiamW: there was not
[13:12:11] LiamW: here is EXACTLY what I did: https://gist.github.com/liamwhite/b244047b1166a87c8ed6752df559b1bd
[13:14:33] LiamW: there are not
[13:17:29] LiamW: https://gist.githubusercontent.com/liamwhite/b244047b1166a87c8ed6752df559b1bd/raw/d0b1977d3d4c1c35d4ca36c25bdc60f4fad81bf8/query.txt
[13:17:31] LiamW: looks like this
[13:38:50] LiamW: NL3limin4t0r: just tried HMT again and got this https://gist.githubusercontent.com/liamwhite/b244047b1166a87c8ed6752df559b1bd/raw/b79ab220fd07b9a9503049058caa06ac30abf56f/query2.txt
[13:46:26] LiamW: I have to go for now, be back later probably
[13:46:35] LiamW: has left #RubyOnRails: ("WeeChat 2.3")

2019-06-29

[05:38:17] LiamW: has joined #RubyOnRails
[05:38:39] LiamW: is there a way to use insert_all with a select query instead of a list of hashes
[13:35:37] LiamW: has left #RubyOnRails: ("WeeChat 2.3")

2019-06-18

[00:47:44] LiamW: has joined #RubyOnRails
[00:48:09] LiamW: my tests are failing because activerecord is doing this `User Create (0.5ms) INSERT INTO "users" DEFAULT VALUES RETURNING "id"`
[00:48:21] LiamW: which is wrong because created_at and updated_at among other things are NOT NULL
[00:48:33] LiamW: but I can't for the life of me pin down why this is happening
[00:52:20] LiamW: okay weird I tried inserting a row in the console and rails isn't setting created_at or updated_at
[00:53:55] LiamW: gah, got it
[00:54:06] LiamW: there was a save! call in a before_create that was doing it
[01:12:18] LiamW: has left #RubyOnRails: ("WeeChat 2.3")

2019-06-13

[01:35:03] LiamW: has joined #ruby
[01:36:50] LiamW: is there a way to do the equivalent of String#start_with? at any arbitrary index in a String, without using a regexp?
[02:08:33] LiamW: oops, forgot to put in the original question: can you do it without allocating another string?
[02:10:41] LiamW: I want to keep string allocations down in my lexer
[02:28:04] LiamW: mutating the string is fine
[02:28:32] LiamW: I suppose it's fine to slice off a chunk each time
[02:43:17] LiamW: I might have to potentially deal with pathological inputs
[02:43:31] LiamW: so that may not be ideal
[02:43:47] LiamW: I'll just mutate the string
[02:49:41] LiamW: That's probably not going to work out very well for you
[02:50:11] LiamW: What you can much more easily get is the bytecode, through RubyVM
[04:20:40] LiamW: has left #ruby: ("WeeChat 2.3")

2019-05-10

[13:33:32] LiamW: has joined #RubyOnRails
[13:33:59] LiamW: doing a rails 6 preview for my app
[13:34:10] LiamW: how do I get rid of all the action mailbox crud from my routes
[13:38:05] LiamW: if it helps (config/routes.rb for actionmailbox is unconfigurable) I don't want action mailbox at all
[13:42:30] LiamW: there are also some activestorage routes I didn't realize were present last time around and want to get rid of them
[13:53:14] LiamW: I changed my require line in application.rb to remove the railties for action mailbox and active storage
[13:53:19] LiamW: that... kind of worked
[13:55:47] LiamW: oh, apparently the rest were from action text
[14:18:36] LiamW: has left #RubyOnRails: ("WeeChat 2.3")

2018-03-20

[01:47:39] LiamW: has joined #ruby
[01:48:23] LiamW: I have a strange problem
[01:48:51] LiamW: are there errors that begin; ...; rescue; end cannot catch?
[01:49:47] LiamW: this is happening to me: https://gist.github.com/liamwhite/552d9c2903cfc7ebe1cf63721d2b7808
[01:50:42] LiamW: RUBY_VERSION = "2.5.0" etc
[01:55:43] LiamW: never mind I'm dumb
[01:55:48] LiamW: it's an Exception not an Error
[01:55:50] LiamW: has left #ruby: ("WeeChat 2.0.1")

2018-03-10

[05:02:51] LiamW: has joined #RubyOnRails
[05:04:54] LiamW: is there a way to prevent activerecord from ever writing to a column
[05:05:33] LiamW: example: I select the model, I read the column, I make some changes, the update set ... query doesn't include the column when writing back
[05:06:16] LiamW: I set up a counter cache column that is managed by the database and I don't want activerecord to be able to get it to desync
[05:16:38] LiamW: ignored_columns doesn't work
[05:21:59] LiamW: okay, found out
[05:22:12] LiamW: Table.columns.delete_if { |c| c.name == 'a_counter_cache' }
[05:22:17] LiamW: works just fine
[05:22:34] LiamW: rails won't update the column anymore after running that
[05:27:17] LiamW: has left #RubyOnRails: ("WeeChat 2.0.1")

2018-03-03

[01:52:17] LiamW: has joined #ruby
[01:52:26] LiamW: im setlocal_OP__WC__0 what does WC stand for?
[03:04:01] LiamW: thanks for all the help...
[14:59:50] LiamW: has left #ruby: ("WeeChat 2.0.1")

2018-02-26

[03:55:34] LiamW: has joined #RubyOnRails
[03:55:44] LiamW: stupid question
[03:55:59] LiamW: when I set the stderr_path for my unicorn it logs every request it receives
[03:56:04] LiamW: how do I disable this
[03:56:16] LiamW: I want to see warnings and errors only
[03:58:21] LiamW: the request lines are not prefixed with "I, " so something is writing directly to stderr
[03:58:26] LiamW: instead of through the logger
[04:12:34] LiamW: passing -N gets it to stop logging the requests, but now it also seems to log nothing
[12:04:24] LiamW: has left #RubyOnRails: ("WeeChat 2.0.1")

2018-02-24

[16:53:32] LiamW: has joined #RubyOnRails
[16:58:57] LiamW: has left #RubyOnRails: ("WeeChat 2.0.1")

2018-02-21

[00:39:55] LiamW: has joined #RubyOnRails
[00:40:31] LiamW: https://gist.github.com/anonymous/ec5eae0adc1130100c84efcdaf26516b
[00:40:42] LiamW: I have a bunch of these queries that have been running for days
[00:40:44] LiamW: are they safe to kill
[00:46:46] LiamW: rails creates them
[00:47:13] LiamW: stackoverflow & prior knowledge
[00:47:26] LiamW: when you deploy to production rails doesn't read from the schema file, it instead reads the schema from the database directly using these queries
[00:47:53] LiamW: because they're taking up connection slots
[00:47:55] LiamW: I only have so many
[00:48:11] LiamW: also they've been running for 16 days
[00:48:12] LiamW: I just checked
[00:48:20] LiamW: safe to say they're not ever going to return results
[00:49:14] LiamW: this is a question about rails
[00:49:22] LiamW: I know how to use postgres
[00:49:31] LiamW: rails originates the query, I need to know if it's safe to kill
[01:49:09] LiamW: has left #RubyOnRails: ("WeeChat 2.0.1")

2018-01-15

[01:39:36] LiamW: has left #RubyOnRails: ("WeeChat 1.8")

2018-01-14

[16:30:37] LiamW: has joined #RubyOnRails
[16:35:27] LiamW: https://github.com/rails/rails/issues/21948
[16:35:29] LiamW: I'm having this problem
[16:35:43] LiamW: is there anything I can do about it that is not already a suggested workaround in the comments
[19:39:38] LiamW: any ideas for the csrf thing
[19:40:07] LiamW: I believe I tried or looked into every suggested solution and workaround in there
[21:53:20] LiamW: desnudopenguino: I'm still having csrf issues :/
[21:53:31] LiamW: prod only, I tried everything I could think of
[21:53:36] LiamW: https://github.com/rails/rails/issues/21948
[21:53:40] LiamW: and everything in here
[23:43:00] LiamW: desnudopenguino: I think I figured it out
[23:43:13] LiamW: the secureheaders gem was setting SameSite=Lax on my session cookie
[23:43:21] LiamW: I disabled that and things seem to work now

2018-01-01

[22:43:35] LiamW: has joined #RubyOnRails
[22:44:01] LiamW: I'm trying to rescue_from ActionController::UnknownFormat but rails isn't rescuing it, why not?
[22:44:07] LiamW: (rails 5.1.4 on ruby 2.5)
[22:45:47] LiamW: ah damnit never mind
[22:45:50] LiamW: I had an error in my rescue_from block
[22:57:43] LiamW: has left #RubyOnRails: ("WeeChat 1.8")

2017-08-07

[00:14:57] LiamW: impermanence: what exactly does it do?
[00:15:36] LiamW: it looks like a mapreduce sort of thing
[00:16:32] LiamW: no this isn't map reduce
[00:16:41] LiamW: but there's shorthand for this
[00:16:59] LiamW: chunk and group_by
[00:20:23] LiamW: >> Process.wait
[00:20:34] LiamW: wat, it didn't error?
[00:20:53] LiamW: "Forbidden syscall waitpid"
[00:21:35] LiamW: how do I stop getting nerd baited
[00:26:11] LiamW: what's with the Pair class
[00:26:33] LiamW: ACTION leaves impermanence to go ponder its existence
[00:27:51] LiamW: yeah but why do you need a pair class
[00:27:57] LiamW: also you can tab complete nicks
[00:28:54] LiamW: why not just a 2-tuple (array)
[01:18:00] LiamW: has left #ruby: ("WeeChat 1.8")

2017-08-06

[16:40:17] LiamW: has joined #ruby
[16:40:35] LiamW: so I've noticed that Kernel#` when called in a tight loop tends to create zombies
[16:40:54] LiamW: would that be a bug in ruby or in libc?
[16:42:16] LiamW: loop { Process.wait } reaps them, obviously
[16:42:40] LiamW: but they shouldn't be sticking around in the first place
[17:24:23] LiamW: apeiros: but how could it be waiting if it created a zombie?
[20:47:02] LiamW: apeiros: 4_500_000.times { `echo` }
[20:47:05] LiamW: seems to do it
[20:47:25] LiamW: (that'll take 10-15 minutes)
[20:47:54] LiamW: I'm testing with a C version to see if I can get the same bug
[20:48:00] LiamW: it might be ruby just failing to wait()
[20:50:36] LiamW: C version didn't bug

2017-07-24

[04:11:28] LiamW: has left #RubyOnRails: ("WeeChat 1.8")

2017-07-23

[17:46:11] LiamW: http://jeromedalbert.com/how-dhh-organizes-his-rails-controllers/
[17:52:44] LiamW: asking again because I wasn't answered earlier:
[17:52:47] LiamW: <LiamW> why aren't the *.rubyonrails.org domains served via tls?
[17:55:49] LiamW: TLS = transport layer security
[19:14:51] LiamW: psql> \d OrderStatuses
[19:28:40] LiamW: wow I wonder why it says that the table doesn't exist
[19:30:18] LiamW: do this in your migration instead add_reference(:orders, :order_status, {:foreign_key=>true})
[19:31:20] LiamW: you're trying to reference :OrderStatuses
[19:31:22] LiamW: for some reason
[19:31:41] LiamW: idk you haven't linked the migration file
[19:34:31] LiamW: gist the contents of the migration file
[19:34:45] LiamW: the table literally doesn't exist, read the error message
[19:34:56] LiamW: it's trying to reference a table called OrderStatuses
[19:35:04] LiamW: the table is actually called order_statuses
[19:36:58] LiamW: wrong migration
[19:37:10] LiamW: gist 20170704220741_add_foreign_key_to_orders.rb
[19:38:49] LiamW: see that line right there `add_reference :orders, :OrderStatus, foreign_key: true`
[19:38:51] LiamW: that is wrong
[19:39:05] LiamW: it needs to be `add_reference :orders, :order_statuses, foreign_key: true`
[19:39:59] LiamW: actually it needs to be `add_reference :orders, :order_status, foreign_key: true` because pluralization but that's why your migration won't work
[22:28:41] LiamW: I would think that at least defending the documentation pages against trivial MITM attacks should be high up on the list of things to do
[22:30:52] LiamW: they do in an otherwise properly-configured setup
[22:31:49] LiamW: if you're going to make a point about using EV certs, EV certs don't provide any special level of protection that DV doesn't https://www.troyhunt.com/on-the-perceived-value-ev-certs-cas-phishing-lets-encrypt/
[22:34:27] LiamW: preload the cert and use a public key pin
[22:34:41] LiamW: that will get you the vast majority of the way to blocking those attacks
[22:38:10] LiamW: that isn't the point of the article
[22:38:31] LiamW: the point is that both EV and DV will keep your connection _private_ and that the difference between them is mostly irrelevant
[22:42:31] LiamW: 03:12:26 < *> Moonlightning discovers the Rails docs are a website that doesn't support TLS
[22:42:34] LiamW: 03:12:49 <Moonlightning> okay, how long until we get attacks by spoofing API docs and tricking developers into introducing security holes into their apps?
[22:42:53] LiamW: is the context
[22:43:13] LiamW: normally I wouldn't care but for how easy it is to set up a DV cert using e.g. letsencrypt I felt it worthwhile to pass that on
[22:43:29] LiamW: as in "5-10 minutes of setup" easy
[22:44:45] LiamW: the other thing about getting TLS is that it will put the actual official rails documentation above APIDock in google search results
[22:46:52] LiamW: based on what's written here https://blog.cloudflare.com/secure-and-fast-github-pages-with-cloudflare/ you can simply use a TLS proxy to fetch securely from GH pages and then serve to the domain itself
[22:47:06] LiamW: it need not be cloudflare, in case you don't like the "all eggs in one basket thing"
[22:47:15] LiamW: it can just be a simple VPS running nginx
[22:49:26] LiamW: could host the static pages for real on aforementioned VPS, and update them automatically on push to the github pages repo via a webhook
[23:02:41] LiamW: on the non technical aspect I think that having an explicit enumeration of genders is probably a bad idea
[23:05:53] LiamW: sooner or later you'll end up with someone in your data that doesn't fit any precise definition of male or female
[23:06:40] LiamW: if you meant to record sex, then you could probably get away with that
[23:07:17] LiamW: I'm not referring to trans
[23:07:56] LiamW: I'm also not referring to the sort of "gender of the day" people that you might think I am
[23:08:04] LiamW: I'm just saying that it's not as meaningful as you probably think it is