tbuehlmann

Activity Graph

Page 1 of 44 | Next »

2019-01-18

[07:37:05] tbuehlmann: makara: remove those spaces before/after ( and )
[07:40:23] tbuehlmann: the following will not raise an error: def index_for(words, word); end; index_for(%w{Mary had a little lamb}, "little")

2019-01-15

[08:11:19] tbuehlmann: havenwood: heh
[11:51:51] tbuehlmann: what's the problem with strings containing newlines?
[12:23:15] tbuehlmann: sunsea: you don't need a lot of math to get started
[13:32:10] tbuehlmann: za1b1tsu: when having a jsonb column, you'll work with a simple array

2019-01-14

[09:55:54] tbuehlmann: alexterziev: can you gist the stacktrace for that error? what line causes it?
[10:04:28] tbuehlmann: what's in app/controllers/application_controller.rb:214?
[10:11:56] tbuehlmann: looks to me like you're calling BigDecimal.new somewhere with a hash instead of a string

2019-01-12

[08:40:50] tbuehlmann: THKitten: what user runs your rails app/sidekiq process and what permissions does this user have on the pid file?
[10:12:46] tbuehlmann: take my like
[12:00:59] tbuehlmann: catbusters: `ProductDetails.belongs_to :product` sounds right to me. it depends on the product being there
[12:12:18] tbuehlmann: run `ls -l <path to file>` and see what user is mentioned there
[12:41:50] tbuehlmann: THKitten: get to go. I assume there's something with the permissions or user that's executing. good luck with that

2019-01-11

[08:20:48] tbuehlmann: IGnorAND: you could get a list of latest fights per boxer, something like Fight.order(match_date: :desc).select('DISTINCT ON (boxer_id) *'). this would order fights by match_date and only take the first one per boxer_id
[10:11:41] tbuehlmann: Spaceman77: is this about regular view rendering?
[10:24:11] tbuehlmann: Arkentias: haven't seen that before but could reproduce. adding `, on: :member` helps, though
[10:54:26] tbuehlmann: catbusters: you should have a higher concurrency than 1 either way
[10:55:47] tbuehlmann: something like that, yes. it might differ per app, though
[10:59:46] tbuehlmann: with puma (the default rails application server) you can spawn multiple workers (== processes), each having multiple threads. so one process can handle more than one request concurrently
[11:09:37] tbuehlmann: not really. if you need that API calls response you have to wait for it. you stated the other option, as in doing it in a background job and use some kind of polling. you have to decide if it's worth the trouble or if waiting might just be okay
[11:38:54] tbuehlmann: you're welcome!
[13:25:41] tbuehlmann: Arkaniad: it this an active record model?
[13:26:14] tbuehlmann: oh, he, actually I meant you
[13:26:32] tbuehlmann: then I suggest not overriding the constructor. you always have access to the models errors by calling .errors on the instance
[13:28:03] tbuehlmann: are these associated models? if so, you can validate them when validating the model itself
[13:28:31] tbuehlmann: they get merge into the instance's errors
[13:39:47] tbuehlmann: that's what I was about to suggest. either that or a lazy loaded instance variable: def model_errors; @model_errors ||= []; end
[13:41:49] tbuehlmann: you're welcome!
[13:42:47] tbuehlmann: alexterziev: what's in app/controllers/sessions_controller.rb:30?
[13:44:40] tbuehlmann: it seems @member is an array and not whatever you think it is
[13:46:43] tbuehlmann: it seems that method returns an array now. I suggest debugging at that point or from a rails console
[13:50:58] tbuehlmann: I get to go now, but it seems you're in good hands with Arkentias. good luck with this
[20:15:22] tbuehlmann: benlieb: can you create a small reproduction script so we can fiddle with it? maybe using this template? https://github.com/rails/rails/blob/master/guides/bug_report_templates/active_record_gem.rb
[20:16:56] tbuehlmann: there's also the more active rails slack

2019-01-10

[12:50:34] tbuehlmann: Psy-Q: you could add a catch-all route and respond with whatever you like
[13:11:26] tbuehlmann: Psy-Q: naw, just add a new route as your last route that will catch anything and let a custom controller/action handle it
[16:01:29] tbuehlmann: shouldn't the index include :user_id instead of :user?
[16:07:55] tbuehlmann: shouldn't that be a ping timeout?

2019-01-09

[09:21:56] tbuehlmann: za1b1tsu: up to you really, I think both options are good ones

2019-01-03

[13:32:06] tbuehlmann: Swyper: that's a block you're providing as a method argument. you can run the code from the block in your method by calling `yield`. you can also reference it by having `def function(&block)` and using `block`
[13:38:15] tbuehlmann: well, you wouldn't pass a string as a block, that could easily be a "regular" argument
[13:39:08] tbuehlmann: example: def twice; yield; yield; end; twice { puts('foo') }
[13:40:14] tbuehlmann: if you just want to reverse something, use a regular argument: def reverse(string = 'hello'); string.reverse; end
[16:05:16] tbuehlmann: Ookma-Kyi: did you just posed that question and just pasted a link?
[16:07:07] tbuehlmann: they will probably all work very well, it's up to you and what tech you know/want to learn
[16:16:39] tbuehlmann: I don't know what framework is the best fit as I only know rails very well
[16:18:28] tbuehlmann: people are leaving everything that is not js :)
[16:20:36] tbuehlmann: I don't know the exact requirements and I don't know django and nodejs enough to make a good suggestion
[16:24:36] tbuehlmann: there are by far more php developers than rails developers, I assume
[16:25:04] tbuehlmann: (comparing a language with a framework here, but you'll get what I mean)
[19:14:00] tbuehlmann: orbyt_: for filtering or what's the usecase?
[19:16:06] tbuehlmann: a simple start for that usecase could be a bunch of model scope that you'd just call: Star.with_foo(params[:foo])
[19:16:17] tbuehlmann: handling the presence of the argument in the scope itself
[19:19:40] tbuehlmann: Star.in_main_sequence(params[:whatever]).larger_than_the_sun(params[:whatever]) and so on
[19:19:51] tbuehlmann: they are chainable as a scope should always return a relation
[19:21:42] tbuehlmann: right, that'd be the query param
[19:24:33] tbuehlmann: I don't know the exact usecase. so you can filter on stages? if so, have a ?stage=name-of-stage query param
[19:26:08] tbuehlmann: well, a simple way

2019-01-02

[14:49:02] tbuehlmann: it does not mutate the string but returns a new one. different story for .gsub! which mutates (or returns nil if no changes were made)

2018-12-26

[13:26:59] tbuehlmann: marz_d`ghostman: https://github.com/sinatra/sinatra/blob/v1.4.6/lib/sinatra/base.rb#L1081-L1085 for example
[17:09:30] tbuehlmann: Andr3as: can you paste the code which generates the button? I assume you're using the method incorrectly
[17:14:54] tbuehlmann: you probably just need to use icon('far', 'eye').html_safe
[17:15:34] tbuehlmann: using the block syntax might work as well: <%= button_to new_signal_read_path, remote: true do %><%= icon('far', 'eye') %><% end %>
[17:15:54] tbuehlmann: what exactly does the #icon method do?
[17:16:07] tbuehlmann: it's possible you're concatenating strings and they are not html safe
[17:30:33] tbuehlmann: mh, okay. I always used this: https://github.com/bokmann/font-awesome-rails

2018-12-25

[10:30:47] tbuehlmann: the obvious: /limit: 1,/
[10:40:05] tbuehlmann: do you really want a regexp or do you just care about the number?
[10:41:40] tbuehlmann: this? /limit: \d+,?/
[10:51:26] tbuehlmann: xco: then capture whitespace and commata, too?
[10:56:45] tbuehlmann: I suggest reading up on regexps then

2018-12-22

[08:49:17] tbuehlmann: gambl0r3: have an example of what you mean?
[17:38:39] tbuehlmann: creamme: you might want `link_to(year, meals_path(year: params[:year]))` instead
[19:32:35] tbuehlmann: creamme: it's not usual having such a method in the model. where and how is that defined?
[19:55:19] tbuehlmann: you can put that method in the application controller and add a `helper_method :logged_in?` to that so that the view can use it
[19:56:17] tbuehlmann: see https://api.rubyonrails.org/classes/AbstractController/Helpers/ClassMethods.html#method-i-helper_method

2018-12-19

[10:57:28] tbuehlmann: can you describe what you're actually after? what's the usecase?

2018-12-18

[09:59:45] tbuehlmann: IGnorAND: distinct uses all the columns you're selecting
[10:11:34] tbuehlmann: adac: write a custom validation
[10:17:02] tbuehlmann: adac: you didn't write anything about an inclusion validation, but yes, that's one way to do it
[10:19:05] tbuehlmann: IGnorAND: ordering by (in)valid insurance and using DISTINCT ON should work. you can't use the distinct method for that, though, as that uses DISTINCT and not DISTINCT ON. you'll have to use something like .select('DISTINCT ON (foo) *') (or group, which works similarly)
[10:20:52] tbuehlmann: adac: you want some kind of inclusion validation but for multiple (but not all) values from an array?
[10:23:25] tbuehlmann: write a custom validation then
[13:47:29] tbuehlmann: kidPalooma: rails converts times to UTC when inserting/updating/selecting, so all you times in the database are UTC. now you can setup a default timezone which rails will use for conversions in your config/application.rb: config.time_zone = 'Berlin'
[13:59:12] tbuehlmann: sure, just set the value when creating/updating a record
[13:59:58] tbuehlmann: you should be able to call YourModel.update_all(renewed_at: Time.current)
[14:00:52] tbuehlmann: um, well, I guess you can configure that in mysql?
[14:03:19] tbuehlmann: there are some options it seems: https://stackoverflow.com/a/19069310/384293
[14:03:37] tbuehlmann: connecting with a prepared uri string using serverTimezone=UTC could work as well
[14:06:30] tbuehlmann: I don't think there is one, but you can send raw sql to your database

2018-12-17

[13:12:50] tbuehlmann: that's actually a class method being called
[13:35:11] tbuehlmann: can you gist your controllers?
[13:35:41] tbuehlmann: righty, there's something wrong :)
[13:57:49] tbuehlmann: TvL2386: rails assumes your times are saved using UTC and will convert times to it when querying. you should setup config.time_zone and use Time.current instead of Time.now

2018-12-14

[10:17:04] tbuehlmann: tinyhippo: I'd start by installing things using https://ryanbigg.com/2014/10/ubuntu-ruby-ruby-install-chruby-and-you
[10:17:21] tbuehlmann: the official guides are great: https://guides.rubyonrails.org/
[10:18:06] tbuehlmann: and then there are quite a lot of guides and intros on the web. the hartl tutorial, for example. never did that, but I read every other day that people like that one
[10:19:44] tbuehlmann: if you're familiar with laravel, that's great. I assume there're lots of similarities
[10:23:42] tbuehlmann: I'd start with chruby, yea. docker just adds complexity you don't need for a start
[10:27:19] tbuehlmann: you're welcome!

2018-12-13

[06:56:15] tbuehlmann: has joined #RubyOnRails
[06:56:20] tbuehlmann: has joined #ruby
[11:21:44] tbuehlmann: hightower2, should be this: https://github.com/rails/rails/blob/v5.2.2/actionpack/lib/action_dispatch/routing/route_set.rb#L319-L334
[13:26:20] tbuehlmann: ActionDispatch::Http::UploadedFile is an uploaded file, so it's working. it just doesn't have a bytesize method to respond to

2018-12-12

[22:29:28] tbuehlmann: Ping timeout: 250 seconds

2018-12-11

[08:25:06] tbuehlmann: what does your staging database has to do with production?
[08:44:48] tbuehlmann: just create the new database and load the old one using psql
[13:30:52] tbuehlmann: I prefer pry over irb

2018-12-10

[09:21:46] tbuehlmann: xco: rails does it for you. what are you after exactly?
[09:23:16] tbuehlmann: the Gemfile.lock lists the dependencies that might be loaded
[11:24:35] tbuehlmann: it really isn't that much of a difference. more secure, if any, is using rails credentials

2018-12-09

[09:36:14] tbuehlmann: adac: that is certainly possible

2018-12-05

[08:25:56] tbuehlmann: dionysus69: same app (controllers, models, …) but without some gems?
[08:41:49] tbuehlmann: you could play with bundler groups and only require certain gems when needed. `Bundler.require(*Rails.groups)` in config/application.rb is a starting point for that
[08:43:01] tbuehlmann: also estimate the time (money) you're wasting doing this vs just upgrading to a bigger dyno
[08:43:51] tbuehlmann: sounds like a new application to me
[08:45:47] tbuehlmann: I assume just using a bigger dyno is way cheaper than your "optimizations" costs, but well
[08:48:33] tbuehlmann: spending hours into this is unviable to the company as well then?
[08:49:01] tbuehlmann: I'd do the maths once to check if this is worth the trouble

2018-12-04

[08:04:33] tbuehlmann: that also applies to passwords, and you shouldn't use simple password as a consequence of that fact

2018-12-01

[11:28:20] tbuehlmann: dionysus69: doesn't sound like a model validation to me then
[12:07:45] tbuehlmann: gavit: have you tried it?
[12:10:10] tbuehlmann: I'd think so, as db:reset does db:drop and db:setup, where db:setup does db:create, db:schema:load and db:seed
[12:10:26] tbuehlmann: you might be after db:migrate:reset
[12:10:33] tbuehlmann: which runs db:drop, db:create and db:migrate
[12:30:03] tbuehlmann: gavit: what exactly do you have?
[12:33:28] tbuehlmann: you probably mean Employment.new(:person => Person.find_by(first_name: "e")) (or Employment.new(person: Person.find_by(first_name: "e")))
[12:37:22] tbuehlmann: remove those spaces

2018-11-29

[10:17:16] tbuehlmann: note that .distinct(:id) doesn't do what you think it does as it's basically the same as just .distinct
[10:18:00] tbuehlmann: I haven't followed in detail and don't know
[10:20:36] tbuehlmann: .distinct works on all the selected columns (which obviously works when only selecting one column). if one want to distinct on one column while selecting more than one, use DISTINCT ON in a select clause
[12:04:40] tbuehlmann: DaniG2k: what's the problem exactly? what have you tried?
[12:07:59] tbuehlmann: why not simply name it @resource?
[12:11:15] tbuehlmann: I thought of @resource ||= organization.lalala
[12:12:30] tbuehlmann: you could also have a inherited class method that gets called when the base controller is being inherited from, then defining the reader and adding the helper method. but to be honest, this doesn't seem like a good idea to me. it greatly complicates the code, making it harder to read
[12:13:09] tbuehlmann: you could also just define the set_<audit-type> in each controller (I assume there won't be hundreds of them) and it'd be easy enough
[12:13:52] tbuehlmann: there's also https://github.com/hashrocket/decent_exposure that came to mind, but I never used it
[12:14:59] tbuehlmann: as said, you can do that in an inherited class method
[12:15:13] tbuehlmann: I'll give you an example
[12:28:45] tbuehlmann: DaniG2k: something like this: https://gist.github.com/tbuehlmann/edbcea1f4719cf0d28b236e3d1b372af
[12:29:40] tbuehlmann: but again, I guess I wouldn't do it. this makes things harder to reason about. and if you really want that, decent_exposure might just do that
[12:30:43] tbuehlmann: you might also need to call `super` in self.inherited, btw
[12:40:32] tbuehlmann: instead of having a base controller you could also have a module doing the same thing, whatever you like

2018-11-28

[17:21:54] tbuehlmann: havenwood: nice!

2018-11-27

[16:03:14] tbuehlmann: adgtl, see: https://github.com/plataformatec/devise/wiki/How-To:-Stub-authentication-in-controller-specs
[16:14:34] tbuehlmann: that's from activesupport and there's no such pendant in ruby
[16:15:18] tbuehlmann: do you mean activerecord?
[16:16:18] tbuehlmann: you can use that without using rails, if that's what you mean
[16:32:33] tbuehlmann: adgtl: that also works for minitest
[16:32:51] tbuehlmann: https://github.com/plataformatec/devise/blob/v4.5.0/lib/devise/test/controller_helpers.rb
[16:36:07] tbuehlmann: have you tried it?
[16:54:58] tbuehlmann: `as` is not for that
[16:57:54] tbuehlmann: ah, you intend to use that backdoor thing?
[17:11:06] tbuehlmann: adgtl: try including Warden::Test::Helpers and running `login_as create(:user)`
[17:12:51] tbuehlmann: login_as works for me ¯\_(ツ)_/¯
[17:15:52] tbuehlmann: ah, there's also Devise::Test::IntegrationHelpers
[17:15:58] tbuehlmann: include that and use sign_in, works for me as well
[17:16:34] tbuehlmann: that is using Warden::Test::Helpers internally
[17:21:20] tbuehlmann: looks good to me
[17:22:08] tbuehlmann: what's in your controller?
[17:25:51] tbuehlmann: are you certain you saved the pads_controller_test.rb file? just to be sure
[17:28:25] tbuehlmann: no idea then

2018-11-25

[17:15:57] tbuehlmann: I often recommend https://ryanbigg.com/2014/10/ubuntu-ruby-ruby-install-chruby-and-you

2018-11-23

[12:50:21] tbuehlmann: pavelz: can you gist your form code?
[12:58:07] tbuehlmann: can you add the params that are submitted to the gist?
[13:01:25] tbuehlmann: shouldn't that one key be space_template_nodes_attributes instead of space_template_nodes? have you tried using the regular form_for and fields_for instead of the simple_form ones?
[13:09:34] tbuehlmann: either pre-build the associated "empty" records in the controller or use a library such as cocoon that'll add items kind of dynamically
[13:30:49] tbuehlmann: well, it's really only the name of the field that's important, so you can do anything you want using js
[13:33:09] tbuehlmann: I don't know why adding fields to a functioning form would lead to CSRF errors
[13:33:31] tbuehlmann: btw, do you have accepts_nested_attributes_for in your SpaceTemplate model?
[13:41:12] tbuehlmann: I'm asking because you only get the space_template_nodes_attributes params key if your @space_template object responds to #space_template_nodes_attributes=
[13:43:42] tbuehlmann: you shouldn't get an array in the first place, I think. it should be a hash like {'0' => {…}, '1' => {…}, …}
[14:42:50] tbuehlmann: you're welcome!
[16:41:02] tbuehlmann: emers2n: there's no built-in method to do that using js. so, yeah, you'll need to roll your own
[16:41:21] tbuehlmann: adgtl: you want `belongs_to :user, optional: true`

2018-11-17

[11:24:21] tbuehlmann: 110041 <tbuehlmann> djass2: no idea
[11:27:40] tbuehlmann: right, but maybe rails can't register your change because of docker/linux and therefore can't reload the code
[11:35:17] tbuehlmann: that's not what I meant. rails listens for file changes and reloads on certain file changes. if there's a problem with docker or the image and file changes from outside are not "reported" inside docker, rails won't reload the code
[11:36:51] tbuehlmann: but I found your other problem :)
[11:36:56] tbuehlmann: or rather the solution
[11:38:16] tbuehlmann: https://gitlab.com/jasmin.bellance/api-test/blob/2f5164e4e4425686b96a5b3e38b5bdc015a6df1f/api/app/views/layouts/application.html.erb#L10 <-- you need this javascript
[11:41:36] tbuehlmann: to the code reloading issue: can you open a rails console inside docker and run this? https://gist.github.com/tbuehlmann/1041d3302057d540d8e83da328fd8deb
[11:41:52] tbuehlmann: then change a controller, save it and check if there's any output in the rails console
[12:04:46] tbuehlmann: how does the line with the application javascript thingy look like now? also, did you do the thing with the rails console?
[12:06:38] tbuehlmann: regarding CSRF: check if the generated html includes "/assets/rails-ujs.self-<timestamp>.js"
[12:07:04] tbuehlmann: is that file referenced in your page?
[12:08:26] tbuehlmann: does it include <script src="/assets/rails-ujs.self-<some-string>.js?body=1" data-turbolinks-track="reload"></script>?
[12:09:04] tbuehlmann: I don't mean the view file, I mean the browser page's source code, just to be sure
[12:09:15] tbuehlmann: if not, you haven't correctly included the file. how does the like look like now?
[12:10:56] tbuehlmann: great. then the form should work
[12:12:56] tbuehlmann: that's a different issue, right
[12:13:10] tbuehlmann: regarding your reloading issue: have you tried what I suggested?
[12:19:06] tbuehlmann: 124144 <tbuehlmann> then change a controller, save it and check if there's any output in the rails console
[12:19:06] tbuehlmann: 124128 <tbuehlmann> to the code reloading issue: can you open a rails console inside docker and run this? https://gist.github.com/tbuehlmann/1041d3302057d540d8e83da328fd8deb
[12:20:09] tbuehlmann: "not working" as in there's no output?
[12:23:59] tbuehlmann: can you gist the output?
[12:26:16] tbuehlmann: that is not what I meant, I meant output in the rails console in which you've called Listen.to
[12:34:05] tbuehlmann: can you open a rails console inside docker and run this? https://gist.github.com/tbuehlmann/1041d3302057d540d8e83da328fd8deb
[12:34:18] tbuehlmann: then change a controller, save it and check if there's any output in the rails console
[12:41:05] tbuehlmann: so, no output?
[12:41:38] tbuehlmann: okay. what happens when you open bash in docker, change a controller using vim and save? do you get output then?
[12:44:27] tbuehlmann: really, no idea then. I still assume docker doesn't correctly report the file changes so rails can't know when to reload code, but I can't prove it
[12:44:45] tbuehlmann: so I think it's not a rails issue, but a docker issue
[12:47:41] tbuehlmann: I can't follow
[12:49:35] tbuehlmann: yes, I don't know what exactly what displayed output and what didn't
[12:58:27] tbuehlmann: it's not about the changes not being made, it's about the "reporting" changes part that might be off
[12:59:17] tbuehlmann: but I'm not really an expert in that, I don't know when and how file changes are propagated
[12:59:33] tbuehlmann: but I still think it's that and that it's a docker issue
[13:00:14] tbuehlmann: again, I believe you that the changes are made. I just think they are not reported correctly, so rails listening to file changes doesn't get the memo
[13:00:32] tbuehlmann: try this same thing not in docker but on your host system, the result might differ
[13:03:34] tbuehlmann: I can't explain it, since I don't know how that works exactly in linux
[13:03:44] tbuehlmann: this is just an assumption
[13:06:06] tbuehlmann: you got to be kidding me
[13:07:54] tbuehlmann: are you on windows by any chance?
[14:23:26] tbuehlmann: https://forums.docker.com/t/file-system-watch-does-not-work-with-mounted-volumes/12038
[14:23:50] tbuehlmann: not sure if this is correct today, but it seems there are issues with windows and file system watching
[14:26:54] tbuehlmann: they update, but do they notice watchers/listeners?
[14:29:33] tbuehlmann: uh? how's it working after restarting puma?
[14:30:18] tbuehlmann: when you restart puma, then change a controller, it reloads the code?
[14:35:31] tbuehlmann: that fits with my assumption. when starting rails (or puma) and accessing constants, it loads them from your files. the expected behaviour when files change is that rails "forgets" about loaded constants and reloads them when accessed. as rails is not being notified about file changes, no reloads are happening
[14:36:02] tbuehlmann: it's probably the windows and docker combination, as file changes are not propagated properly
[14:36:07] tbuehlmann: this is not a rails issue
[14:42:07] tbuehlmann: it works for me and I'm not on windows
[14:42:23] tbuehlmann: maybe it's windows, maybe the docker version, maybe a combination, how knows
[14:42:29] tbuehlmann: but I'm certain it's not rails
[14:45:09] tbuehlmann: gavit_: you should probably change that
[14:46:30] tbuehlmann: gavit_: what that your password you pasted into the channel?
[14:46:45] tbuehlmann: djass2: that might help
[14:47:34] tbuehlmann: djass2: my host system is windows, and in an ubuntu vm using docker, I don't have that issue