Activity Graph

Page 1 of 45 | Next »


[08:53:20] tbuehlmann: dionysus69: https://github.com/ruby/ruby/blob/v2_6_2/ext/psych/lib/psych/core_ext.rb#L12-L14


[14:27:22] tbuehlmann: modules are classes, but this is not what you're after I guess. why wouldn't you be able to test a module?
[14:44:14] tbuehlmann: what's the problem? what error do you get?


[13:06:00] tbuehlmann: are you running `$ bundle update rails`?
[13:15:27] tbuehlmann: Animazing: yeah, make sure it all works out
[13:46:12] tbuehlmann: if RouteuPoint belongs to a city, then yes, that's how it should be modeled


[09:59:21] tbuehlmann: Spaceman77: yes, see https://guides.rubyonrails.org/active_record_validations.html#conditional-validation
[14:14:24] tbuehlmann: what's your definition of "repeating"?


[07:03:27] tbuehlmann: Cork: have an example of what you mean?
[07:14:53] tbuehlmann: I'd say the before_create should be a before_validation
[07:28:10] tbuehlmann: before_validation should be in the transaction already
[07:28:35] tbuehlmann: another approach: can't you make sure the record exists before creating the private network?
[07:37:20] tbuehlmann: heh, you're welcome!
[08:30:34] tbuehlmann: what does "database management" mean exactly?
[08:33:12] tbuehlmann: why wouldn't you do that in the rails app?
[08:42:01] tbuehlmann: web and api sounds like a rails app to me. a cli could be a gem (or script), but using the api, not interacting with the database on its own
[14:47:24] tbuehlmann: no, that's a pretty big topic


[09:22:00] tbuehlmann: solely relying on rails validations can lead to errors
[09:26:11] tbuehlmann: is this original code? do you just assign a random number?
[09:27:52] tbuehlmann: yeah, then go and rescue that exception. if you don't do it, errors could be raised
[09:28:11] tbuehlmann: do you really a need a random number, though? what purpose does it have?
[09:30:57] tbuehlmann: okay, I don't have anything to add, then
[10:03:38] tbuehlmann: sure, either that or `path ||= Pathname.new(default_path)`. default_path could be a Pathname already, but that's up to you. you could also assign the default path before going into the conditions


[08:57:29] tbuehlmann: it's a micro optimization not worth talking about. so, "no", they do not perform better
[09:24:27] tbuehlmann: I can see that tweet, mister


[10:09:31] tbuehlmann: rizwan_: you probably don't have bundler installed. try running `gem install bundler`
[10:12:46] tbuehlmann: npm has nothing to do with ruby, don't do that
[10:13:18] tbuehlmann: what exactly happens when you run `gem install bundler`?
[10:17:31] tbuehlmann: you're running `ruby console`, you probably mean `rails console`
[10:20:15] tbuehlmann: even after installing bundler?
[12:14:55] tbuehlmann: you're using an _url helper, so I assume this is a system test?
[12:16:30] tbuehlmann: either way, there's probably no route for that. you want edit_task_url(@task)
[12:17:10] tbuehlmann: should be edit_task_path then
[12:20:25] tbuehlmann: right, as said, there's no such route. try edit_task_path(@task)
[12:21:32] tbuehlmann: edit_task_path(@task) will return that string
[12:22:13] tbuehlmann: you're welcome!


[00:10:36] tbuehlmann: Ping timeout: 252 seconds
[00:12:25] tbuehlmann: has joined #ruby
[00:12:25] tbuehlmann: has joined #RubyOnRails
[14:24:05] tbuehlmann: I also recommend the official guides. there's also a part for api-only applications: https://guides.rubyonrails.org/api_app.html


[13:41:47] tbuehlmann: adding `driven_by :selenium, using: :headless_chrome, screen_size: [1400, 1400]` doesn't work for you?
[13:51:42] tbuehlmann: remove all the Capybara.register_driver stuff and the Capybara.server_port and try again
[13:52:34] tbuehlmann: also, do you have the `js: true` metadata in the example that you're testing?
[13:53:03] tbuehlmann: https://github.com/tbuehlmann/til/blob/master/rails/headless-system-tests.md - this is all I got and that works for me
[14:01:01] tbuehlmann: syndikate: sure
[14:01:18] tbuehlmann: pavelz: add an `as: 'hello'` option to your route
[14:01:34] tbuehlmann: I'd also reconsider this, maybe `resources` is what you want
[14:43:02] tbuehlmann: I think that'll change the type to :feature, maybe overriding it
[15:57:33] tbuehlmann: .where(published: true) could be a default which is overridable by the user
[16:00:42] tbuehlmann: it's often easier to first apply the defaults and only later apply the user's needs


[09:17:30] tbuehlmann: c-c: you can call `yield your_instance` which will run the block with that variable as block variable
[09:19:14] tbuehlmann: https://gist.github.com/tbuehlmann/dd07be2f539cc8c7fc927df2eef2b04a
[11:44:33] tbuehlmann: I'd just make this migration irreversible ¯\_(ツ)_/¯
[12:13:24] tbuehlmann: yarn is still in. you probably mean that webpacker is used for javascript instead of sprockets
[12:58:21] tbuehlmann: dionysus70: have you even checked google?


[11:27:26] tbuehlmann: I don't think there's a method for that
[12:04:11] tbuehlmann: husam212: I don't think so. as helpers are modules, you could include these modules into your object and just call the methods
[12:59:59] tbuehlmann: Psy-Q: right, you'd route that to a custom controller action that would respond whatever you like
[13:08:57] tbuehlmann: right, it renders the public/404.html. for json requests, it'll render {"status":404,"error":"Not Found"}


[13:26:09] tbuehlmann: arkentias, YourModel.find(id) will find by id. you can then call association methods on that object to retrieve that association
[13:27:50] tbuehlmann: do you mean finding both records with a single sql query?
[13:31:59] tbuehlmann: sure, sounds easy. what's the problem exactly?
[13:33:20] tbuehlmann: how do you render the json right now?
[13:43:27] tbuehlmann: arkentias, try this: `render json: @transaction.as_json(include: [:procedure])`
[13:49:52] tbuehlmann: you're welcome


[08:41:45] tbuehlmann: pavelz: try `render 'admin/user/list', locals: {locked: true}`
[13:55:43] tbuehlmann: are the array elements supposed to be json?
[13:58:58] tbuehlmann: have you tried this? array.map { |element| JSON.parse(element) }
[14:04:32] tbuehlmann: great. why isn't the whole thing json in the first place?
[15:59:09] tbuehlmann: guessing is not enough, you should find out what really slows it down first


[10:40:31] tbuehlmann: right, we rather handle objects as "truthy" and "falsy" most of the time
[10:55:38] tbuehlmann: yeah, I'd check for == true or == false directly then


[10:51:57] tbuehlmann: require the file
[10:53:43] tbuehlmann: it's even in the readme, read it
[12:39:37] tbuehlmann: nope, I don't think so
[14:16:38] tbuehlmann: I assume you're talking about rails. if so: #deep_symbolize_keys
[14:28:26] tbuehlmann: if order matters, I personally wouldn't use a hash for that. what about using an array?


[08:01:30] tbuehlmann: Cork: sure, just let api.user return an object that responds to the methods you need
[08:02:47] tbuehlmann: you could pass whatever you need
[08:39:13] tbuehlmann: how do you make puma log to puma_access.log?
[08:44:41] tbuehlmann: what config does this set?
[08:56:34] tbuehlmann: GeorgesLeYeti: what setting does this set on puma?
[09:08:50] tbuehlmann: sounds like monday
[15:08:24] tbuehlmann: phaul, feature request: make it so I can navigate the hierarchy with arrow keys :D


[14:54:33] tbuehlmann: you can just leave it as is


[08:47:11] tbuehlmann: they're gone
[10:36:40] tbuehlmann: there's the rack-cors gem, but shouldn't the domain be the same?
[10:42:18] tbuehlmann: sagax: in rails?
[10:48:20] tbuehlmann: try this: sqlite3 database.sqlite3 .schema > schema.sql
[10:49:24] tbuehlmann: what does this have to do with ruby in the first place?


[12:05:30] tbuehlmann: andywww: can you add the code you're running to the gist?
[12:05:39] tbuehlmann: including the stacktrace
[12:50:47] tbuehlmann: andywww: you're using `self.user.id` inside that `DocumentType.all.each`
[12:51:05] tbuehlmann: but you don't have user .user method on the DocumentSelectForm class
[12:56:09] tbuehlmann: NoMethodError - undefined method `user' for DocumentSelectForm:Class <-- that errors comes from using self.user.id on the class level
[13:01:08] tbuehlmann: andywww: .attribute is for defining what attributes are generally available in your model
[13:04:29] tbuehlmann: so you want to change the attribute set depending on the user? this won't go well
[13:12:49] tbuehlmann: I'd check if using fields_for and accepts_nested_attributes_for is an option
[13:14:30] tbuehlmann: well, looks like a model to me
[13:14:38] tbuehlmann: just without the database back
[13:14:59] tbuehlmann: this gets too complicated for me, I can't follow
[13:21:10] tbuehlmann: you can name it whatever you like, form object or model
[13:33:41] tbuehlmann: Psy-Q: yeah, just did that in my reproduction script
[13:35:55] tbuehlmann: have you thought about putting the role/mode/type into the contact model?
[13:37:40] tbuehlmann: can the same contact be associated to different accounts?
[13:38:59] tbuehlmann: well, then using what you got should work, right?
[13:42:07] tbuehlmann: yeah, I guess so. you'll probably need to create the Contactable directly
[13:46:35] tbuehlmann: what prevents you from having unique contacts?
[13:48:19] tbuehlmann: for that you got join tables. did I miss the problem?
[13:52:06] tbuehlmann: I'm sure you could hack into the association and set the mode/role/type :)
[13:54:12] tbuehlmann: oh, wait, rails already does it for me
[13:56:32] tbuehlmann: you need to use a hash, not an sql string: has_many :owners, -> { where(contactables: {mode: 'owner'}) }, through: :contactables, source: 'contact'
[13:56:41] tbuehlmann: (my column is named mode, so change that)
[13:57:06] tbuehlmann: if you have that, it seems to behave like a default_scope as it sets the attribute like the where is
[13:58:57] tbuehlmann: some_account.owners.instance_variable_get(:@association).send(:options_for_through_record) # => [{"mode"=>"owner"}]
[13:59:24] tbuehlmann: you're welcome
[14:09:10] tbuehlmann: Psy-Q: right :)
[14:12:54] tbuehlmann: randohinn: looks good. what exactly doesn't work?
[14:17:44] tbuehlmann: rails doesn't understand this as a subdomain. try foo.bar.baz instead of anydomainhere.localhost
[14:19:23] tbuehlmann: you can configure the way rails understands domains, see https://guides.rubyonrails.org/configuring.html#configuring-action-dispatch (config.action_dispatch.tld_length)
[14:20:08] tbuehlmann: setting config.action_dispatch.tld_length to 0 should work for anydomainhere.localhost
[14:22:55] tbuehlmann: config/application.rb or config/environments/*.rb
[14:26:04] tbuehlmann: you're welcome!


[11:01:07] tbuehlmann: app/* is automatically autoloaded, so you don't need to add any path
[11:01:24] tbuehlmann: app/operations/foo/create.rb would then define a Foo::Create class/module
[11:05:15] tbuehlmann: looks good to me. can you reproduce this behaviour locally?
[11:08:08] tbuehlmann: but so should your staging env?
[11:09:19] tbuehlmann: so you're using docker locally, but the staging env differs from that? how does that makes sense? :)
[11:12:08] tbuehlmann: whatever. hard to tell what's wrong if you can't reproduce it locally


[13:03:19] tbuehlmann: danger zone?
[13:48:35] tbuehlmann: eminencehc: just use a different method in your controller action. if that doesn't work, something else is wrong
[13:49:40] tbuehlmann: syndikate: shopify's test suite runs for hours, already parallelized. it totally depends on the app's size and on your testing preferences
[14:05:30] tbuehlmann: I don't know how they do it. the testing preference is about what you think is worth to be tested
[14:05:58] tbuehlmann: nah, it's just you're not my highest priority right now
[14:07:23] tbuehlmann: if you test every nuance of your app, things that are not meant to be tested, that'll surely slow down the test suite. also, slow operations will obviously slow down the test suite, like unnecessary database queries
[14:15:37] tbuehlmann: I wouldn't do that. how would you know the tests you're excluding wouldn't fail?
[14:16:41] tbuehlmann: eminencehc: can you paste the controller code?
[14:17:41] tbuehlmann: (as in: use https://gist.github.com/, not actually pasting the code in this channel)
[14:21:15] tbuehlmann: why not use the regular create action?
[14:22:42] tbuehlmann: you could use the same action but different strong params methods
[14:30:34] tbuehlmann: I wouldn't use a different method. if the differences between regular users and ownser are small, have the same controller with different strong params methods and the same views with conditionals
[14:31:29] tbuehlmann: if the differences aren't that small (different redirects?), consider having a different controller and different views. this is a sane option for when you want to have a dedicated admin UI, too
[14:36:47] tbuehlmann: eminencehc: an example: https://gist.github.com/tbuehlmann/b92f7b671754b56a98b65b09ca0fddc9
[14:37:23] tbuehlmann: I can't say whether this makes sense for your use case, but it's certainly an option
[14:56:12] tbuehlmann: can you gist the complete controller code your have right now?
[15:02:35] tbuehlmann: if done properly, both options should work. but if it works now, great
[15:03:41] tbuehlmann: get to go now, happy hacking!


[09:34:54] tbuehlmann: looks about right
[09:36:46] tbuehlmann: try starting the server with the RAILS_SERVE_STATIC_FILES environment variable set to "1"
[09:38:26] tbuehlmann: yup, you should consider having a reverse proxy in front of the application that directly serves files from the public directory
[09:39:29] tbuehlmann: or configure a CDN that serves the assets. I'd go with nginx as a reverse proxy, though. it has other benefits beside directly serving assets
[09:41:51] tbuehlmann: great, you just need to configure it properly then
[09:56:56] tbuehlmann: you're welcome!
[11:22:49] tbuehlmann: how do you generate the links? can you gist the server log for these requests?
[11:29:54] tbuehlmann: looks good to me
[11:34:20] tbuehlmann: ah, so it's probably the nginx configuration?
[11:46:38] tbuehlmann: you could start by just having a config for /assets
[11:49:23] tbuehlmann: (and probably /packs)
[12:43:52] tbuehlmann: catbusters: spring shouldn't generate that file, bundle install should
[12:49:37] tbuehlmann: regardless of whether spring was responsible for this, I can't recommend enough to not use spring at all
[13:00:02] tbuehlmann: spring just tries to speed up your rails processes. if you don't use spring, it'll work nontheless


[11:43:07] tbuehlmann: jason479: what's the question?
[11:50:24] tbuehlmann: you can nest B inside the A namespace
[11:51:14] tbuehlmann: credentials don't support environment specific credentials yet
[11:51:22] tbuehlmann: you can keep two files
[11:52:21] tbuehlmann: https://gist.github.com/tbuehlmann/671fca8fa29122b39ac9d66b963467ce
[11:53:50] tbuehlmann: it depends on your deployment strategy, I'd say. if you're on heroku, use environment variables. if you're deploying with capistrano, use config files on the server. if it's none of that, you can still use the "old" config/secrets.yml file which is aware of environments
[11:55:59] tbuehlmann: you can also use rails 6.0.0.beta1 which should support environment specific credentials
[11:56:24] tbuehlmann: haven't followed if it's actually in, maybe this helps: https://github.com/rails/rails/pull/33521


[09:57:58] tbuehlmann: `SomeModel.first.inspect` displays timestamps using the database configured timezone, not the application configured timezone. `SomeModel.first.created_at` correctly displays the timestamp using the application timezone, as expected. the code for the inspection is here: https://github.com/rails/rails/blob/v5.2.2/activerecord/lib/active_record/attribute_methods.rb#L352
[09:58:05] tbuehlmann: any idea why that would be useful?
[13:00:11] tbuehlmann: guyzmo: "first" an in ordered by foobars.created_at DESC?
[13:17:07] tbuehlmann: could be this: A.joins(:foobars).order(as.id, foobars.created_at).select('DISTINCT ON(projects.id) projects.*').where(foobars: {title: nil})
[13:17:34] tbuehlmann: although that might be wrong, I'm not sure whether where is applied before or after distinct on :\
[13:30:22] tbuehlmann: guyzmo: is the foobar_position absolut? as in: the first foobar has foobar_position 0?
[13:31:10] tbuehlmann: greengriminal: wanted to write that, I think that's the case
[13:35:49] tbuehlmann: if you only care about the presence of any number, go for `bar_id`. if you care about the presence of the actual foreign record, got for `bar`. either way, you shoud have a foreign key constraint on your database
[13:55:57] tbuehlmann: guyzmo: tell me you're using postgres
[13:59:07] tbuehlmann: got something for you then, just a sec
[14:03:13] tbuehlmann: trickier than expected given that there's a join
[14:09:07] tbuehlmann: A.from('(SELECT as.*, foobars.x AS foobar_x, row_number() OVER (PARTITION BY as.id ORDER BY foobars.created_at DESC) FROM as INNER JOIN "foobars" ON "foobars"."project_id" = "as"."id") as').where(row_number: 1, foobar_x: nil)
[14:09:42] tbuehlmann: I used two of my sandbox models and renamed them to A/as and foobars. this will probably crash as "AS" has a certain meaning in SQL. but you'll get the idea
[14:10:54] tbuehlmann: I'm using a partition so each group of foobars per a get a row_number (1, 2, 3, ...). having that, you can simply do a where(row_number: 1, foobar_x: nil). that foobar_x thingy is a bit hacky and there's probably a better way, but it worked in my example
[14:13:28] tbuehlmann: you're welcome :)
[14:17:23] tbuehlmann: it changes the FROM part of the query
[14:21:08] tbuehlmann: when Foo.has_many :bs: Foo.where(B.select(:a_id))
[14:21:17] tbuehlmann: this will only be one query (including a subquery)
[14:21:33] tbuehlmann: eh, :foo_id, not :a_id :)


[13:11:11] tbuehlmann: sure, fix the code
[13:15:27] tbuehlmann: have you read the thread? when following the trail, you'll get to this: https://github.com/plataformatec/devise/commit/1009096172f2cbc86bcd54d053c89a09be67fb9f


[10:59:03] tbuehlmann: timwis: can you gist your Gemfile?
[11:05:23] tbuehlmann: okay, so '~> 5.2.0' will let you upgrade to 5.2.2, is that good enough?
[11:07:19] tbuehlmann: right, so you can upgrade to 5.2.2. I don't know githubs security policy on activestorage. what version do you need?
[11:10:52] tbuehlmann: `bundle update rails` should update unless another gem dependency prevents it
[11:11:11] tbuehlmann: you can try setting the version to '5.2.2' and try again
[11:13:07] tbuehlmann: what does `bin/rails -v` display? are you on 5.2.2 already?


[12:03:18] tbuehlmann: iirc, it returns the symbol's characters as String#[] does
[12:13:48] tbuehlmann: xco: don't use the `index: true` option but rather use add_index and use a custom index name
[13:56:53] tbuehlmann: "rails also sucks ballz" is a pretty harsh statement, it works for quite some people and companies
[13:57:42] tbuehlmann: so does php, right. I also don't think php sucks ballz


[08:44:55] tbuehlmann: the producer threads puts items in the queue and the consumer threads takes items out of the queue. if a program reaches the end of the file, the program will exit and the threads will be killed, even if they are still doing their things. if you want to wait for the threads to finish their things, you can call .join on them, that's what it's for
[08:49:55] tbuehlmann: right, threads run concurrently to your main thread. they will be killed when the program is exited, though, they don't continue
[09:26:14] tbuehlmann: I put mine in lib/wsdls


[10:17:54] tbuehlmann: keanny479: hey! what exactly do you mean, to "rewrite" the instance variables?
[10:23:32] tbuehlmann: nah, that's fine


[10:14:08] tbuehlmann: https://pbs.twimg.com/media/Bn8ZYxrIMAIBMG3.png:large
[10:18:44] tbuehlmann: nah, the question is just loaded
[10:48:02] tbuehlmann: I don't understand your second sentence
[10:49:08] tbuehlmann: if it's `Foo.has_many :bars` and you want all foos with associated bars, that'd be an inner join: Foo.joins(:bars)
[10:49:25] tbuehlmann: that might return double foos, so you might want to use a distinct
[10:52:08] tbuehlmann: ntt: you can certainly do that. if these defaults are always the same, you could also use after_initialize in your model to set default value
[10:53:39] tbuehlmann: https://gist.github.com/tbuehlmann/0c36c0ac0e81de8b20f54879d3e42227 this will set some_attribute to 'default value' unless it's there
[10:54:01] tbuehlmann: with this, you can simply pass your params into the initializer
[10:55:37] tbuehlmann: if the defaults are always the same, you'd just put them into after_initialize, or am I missing something?
[10:55:55] tbuehlmann: (a different option is to have these defaults as database table defaults, btw)
[10:59:31] tbuehlmann: without the renaming this would simply be: `DeliveryRound.has_many :destinations, through: :missions`. so some_delivery_round.destinations would work
[11:02:18] tbuehlmann: sure, something like this then: https://gist.github.com/tbuehlmann/0c36c0ac0e81de8b20f54879d3e42227
[11:04:00] tbuehlmann: you could replace that hash in line 4 with whatever you have
[11:05:55] tbuehlmann: some_object.public_send(:foo) is like calling some_object.foo
[11:06:11] tbuehlmann: it let's you dynamically call methods on an object using a symbol
[11:08:48] tbuehlmann: you're welcome!
[13:55:56] tbuehlmann: I don't see anything suspicious



[14:04:59] tbuehlmann: reminder_text and reminder_date are table columns?
[14:05:34] tbuehlmann: great, remove that `attr_accessor :reminder_text, :reminder_date` and try again
[14:06:39] tbuehlmann: exactly. rails will check the database tables for the columns and add methods on the model. you're overriding the methods here
[14:08:20] tbuehlmann: you're welcome!
[14:08:36] tbuehlmann: nah, it's an honest mistake
[14:14:35] tbuehlmann: great gist for debugging this issue, btw. it's not every day that we get such good information