tbuehlmann

Activity Graph

Page 1 of 43 | Next »

2018-11-15

[13:35:30] tbuehlmann: logik-bomb: a category could have many "attributes" (colour, number of doors, …), and each record would have one "value" for each attribute the associated category has. "attributes" and "values" being tables
[13:36:36] tbuehlmann: rien_: resolve the conflicts and directly mention a core member
[13:43:40] tbuehlmann: matthewd? *runs*

2018-11-09

[05:45:29] tbuehlmann: elcontrastador: app/validators is a common place and you wouldn't need to adapt any load paths
[09:06:04] tbuehlmann: configuration from config/environments/*.rb take precedence over config/application.rb
[10:13:45] tbuehlmann: I'm usually doing this: RSpec.describe SomeClass do; describe '.some_class_method' do; <examples here>; end ; end

2018-11-08

[09:36:53] tbuehlmann: I don't think so

2018-11-07

[09:33:11] tbuehlmann: I don't fully understand the question, but there's the attr_encrypted gem which can encrypt stuff before storing it in the database and decrypt when you want to read it
[09:34:02] tbuehlmann: I second that, working great for us, too

2018-11-06

[08:40:56] tbuehlmann: ntt: yes, you can use current_user in a before_action
[08:44:13] tbuehlmann: you're using before_action wrong
[08:44:59] tbuehlmann: see https://guides.rubyonrails.org/action_controller_overview.html#filters
[08:53:05] tbuehlmann: consider what?
[08:57:22] tbuehlmann: returning false doesn't do anything. you need to render or redirect in order to avoid running the action
[08:57:39] tbuehlmann: it's in the example on https://guides.rubyonrails.org/action_controller_overview.html#filters

2018-11-05

[10:17:46] tbuehlmann: you'd probably have to use an attr_accessor like a virtual attribute for that. do you have an example?
[10:48:58] tbuehlmann: what about having a validation for server_name and early returning in your default stuff if it's not present?
[14:28:39] tbuehlmann: store it using UTC (which is the rails default) and convert it locally if needed
[14:35:25] tbuehlmann: rails will just do the right thing
[14:40:36] tbuehlmann: drale2k_: when saving any time object, rails will convert it to UTC
[14:41:21] tbuehlmann: drale2k_: you have to somehow save the timezone or allow for setting it later. often times apps allow for users to setup their timezone, saving it in a user record
[14:43:02] tbuehlmann: if it's possible I'd store a string like 'Eastern Time (US & Canada)'
[14:45:15] tbuehlmann: or just time.in_time_zone('Berlin')
[14:50:31] tbuehlmann: never did that

2018-11-01

[10:21:59] tbuehlmann: hightower3: it's a simple getter (https://github.com/rails/rails/blob/v5.2.1/actionpack/lib/action_controller/test_case.rb#L335), and the variable is set here: https://github.com/rails/rails/blob/v5.2.1/actionpack/lib/action_controller/test_case.rb#L519 when processing the "post"
[10:37:31] tbuehlmann: right, I forgot: it's delegated to @controller
[10:37:57] tbuehlmann: so there's no #response method, but #method_missing will pick it up and call #response on @controller
[10:45:09] tbuehlmann: looks like it's just a getter
[10:47:51] tbuehlmann: DaniG2k: can you paste the exact exception message?
[10:52:40] tbuehlmann: can you doublcheck whether the index already exists?
[10:59:13] tbuehlmann: can you ask your database instead of some files?
[11:00:15] tbuehlmann: can you check it?
[11:05:56] tbuehlmann: it seems you or some other person created the index directly in the database without using rails, or your migrations/schema is not correct
[11:10:02] tbuehlmann: not sure how disable_ddl_transaction! behaves in case with an exception (probably just like mysql). did the migration fail earlier so the migration was not successful but the changes wasn't rolled back?
[11:11:38] tbuehlmann: disable_ddl_transaction! disables transactions, so it couldn't roll back
[11:14:51] tbuehlmann: that just has to do with the index (concurrently), not strong_migrations
[11:15:08] tbuehlmann: but well, I guess you got your answer

2018-10-30

[08:10:17] tbuehlmann: you require the application before defining the constant
[08:10:52] tbuehlmann: and `DOCKERIZED = File.exist?("/.dockerenv") ? true : false` could just be `DOCKERIZED = File.exist?("/.dockerenv")`
[08:13:18] tbuehlmann: do you need the constant in your environment.rb file at all?
[08:14:24] tbuehlmann: if not, you could simply put it in a config in application.rb: config.x[:dockerized?] = File.exist?('/.dockerenv'); Rails.configuration.x.dockerized? # => true/false

2018-10-25

[05:04:14] tbuehlmann: skwurl: can you gist what you're trying to do?
[05:06:03] tbuehlmann: ah, you're already getting help over at #RubyOnRails, nvm
[05:13:18] tbuehlmann: skwurl: I suggest you run `rails generate scaffold Project name:string` in your terminal, followed by `rails db:migrate` and then inspect app/controllers/projects_controller.rb and the corresponding views in app/views/projects
[05:13:38] tbuehlmann: there's an ordinary code flow visible in all the controller actions
[05:38:49] tbuehlmann: skwurl: any question in particular?

2018-10-23

2018-10-21

[12:03:54] tbuehlmann: Ping timeout: 252 seconds
[12:04:12] tbuehlmann: has joined #ruby
[12:04:12] tbuehlmann: has joined #RubyOnRails

2018-10-20

[11:52:40] tbuehlmann: Ping timeout: 252 seconds
[11:53:30] tbuehlmann: has joined #ruby
[11:53:30] tbuehlmann: has joined #RubyOnRails

2018-10-18

[13:09:38] tbuehlmann: RougeR: can you gist the whole stacktrace to that error?
[13:18:30] tbuehlmann: I assume app/models/job.rb includes a Job model that inherits from ActiveRecord::Base and that at this point the active record library wasn't loaded
[13:19:51] tbuehlmann: what changed?
[13:23:58] tbuehlmann: where do you require active record and is that file loaded before requiring the job.rb file?
[13:32:44] tbuehlmann: are you certain you're requiring active record before requiring the job?
[14:11:11] tbuehlmann: samort7: it's about your rails process to listen to file changes and act on it
[14:11:41] tbuehlmann: code reloading, for example, so you don't have to restart your rails server after any code change
[14:16:57] tbuehlmann: I'd start with spring :)
[14:18:18] tbuehlmann: see https://github.com/rails/spring: Spring is a Rails application preloader. It speeds up development by keeping your application running in the background so you don't need to boot it every time you run a test, rake task or migration.
[14:19:07] tbuehlmann: sounds like a great idea, but for me (and others) it has been a pain point as it can have some weird behaviour
[14:19:22] tbuehlmann: as in: don't restart the server when it should, running on old code where you wouldn't expect it
[14:34:41] tbuehlmann: you can be lucky and never suffer from it, but when it hits you, you'll debug quite a lot until you figure out that manually restarting spring will solve the issue
[14:50:09] tbuehlmann: to be fair, it works for quite a lot of people I suppose

2018-10-17

[08:30:49] tbuehlmann: marz_d`ghostman: it's plain inside the class? then it's executed when the class is loaded
[08:35:06] tbuehlmann: uh, no, that method shouldn't be called by rspec before your examples
[13:57:54] tbuehlmann: bothari: you can read up on accepts_nested_attributes and fields_for, that's for creating/updating a record and its children using one form. dynamically adding/removing tasks using js is not really supported in rails itself, but there's the cocoon library, which will help doing exactly that

2018-10-09

[09:39:25] tbuehlmann: https://github.com/rails/rails-html-sanitizer might help
[10:52:45] tbuehlmann: davidh38: using pry can be huge. I'm almost always using it when debugging and exploring objects
[10:53:07] tbuehlmann: it's the first gem I add to a rails app's gemfile (pry-rails it is)
[11:25:44] tbuehlmann: `def foo(**kwargs); kwargs; end` where kwargs will be a hash, do you mean that?
[11:39:26] tbuehlmann: I don't think that's easily possible

2018-10-08

[11:04:34] tbuehlmann: maryo_: there are several ways to install ruby, I personally recommend using ruby-install (for installing rubies) and chruby (for switching between installed rubies)
[11:04:46] tbuehlmann: I recommend this: https://ryanbigg.com/2014/10/ubuntu-ruby-ruby-install-chruby-and-you
[11:28:06] tbuehlmann: maryo_: installing ruby can take quite some time, give it a few more minutes and check back
[11:55:11] tbuehlmann: maryo_: using rbenv?
[11:56:30] tbuehlmann: dionysus69: it returns `secrets.secret_key_base || Digest::MD5.hexdigest(self.class.name)` in development
[12:00:41] tbuehlmann: I can't help with rbenv. have you read this? https://github.com/rbenv/rbenv/blob/v1.1.1/README.md
[12:02:53] tbuehlmann: yes, it does: https://github.com/rails/rails/blob/v5.2.1/railties/lib/rails/application.rb#L432-L434
[13:54:09] tbuehlmann: yes. `bundle install` installs the gems mentionend in your Gemfile. `bundle exec <some command>` run the given command in the context of your Gemfile's gems

2018-10-06

[13:56:49] tbuehlmann: mjacob: activemodel and activerecord are different things, so you probably shouldn't mock an activerecord class with an activemodel class, right?
[13:57:49] tbuehlmann: wanna show some code?
[14:06:52] tbuehlmann: can you gist it?
[14:17:40] tbuehlmann: okay, and that doesn't work with an activemodel?
[14:37:53] tbuehlmann: I mean, you could also just test whether the `attribute` method called as expected, not doing it really

2018-10-05

[09:46:34] tbuehlmann: my story exactly
[17:41:31] tbuehlmann: davidh38: what part exactly?
[17:46:11] tbuehlmann: no. what's charge?
[17:47:37] tbuehlmann: if it's not a local variable it's a method. check the controller and the parent controller
[18:05:16] tbuehlmann: davidh38: you could search for "def charge" or search for "charge" in general
[18:11:17] tbuehlmann: no idea then
[18:12:10] tbuehlmann: I wouldn't know why
[19:57:19] tbuehlmann: samort7: we have such a file, it's the schema.rb (or structure.sql)
[20:00:12] tbuehlmann: see https://guides.rubyonrails.org/active_record_migrations.html#migration-overview for an overview on why migrations are useful
[20:02:02] tbuehlmann: well, let's say we only have that file. when you changed the database locally and committed that change, your production rails app would somehow need to determine what exactly changed since its last version
[20:02:25] tbuehlmann: it might calculate a diff from an earlier version of something like that, but that seems too complicated
[20:03:04] tbuehlmann: exactly. and that's easily done with a migration
[20:03:59] tbuehlmann: you're welcome!

2018-10-04

[09:35:06] tbuehlmann: oh? I thought it just checks for an existing validation with the given options
[09:40:20] tbuehlmann: I only see value in such shoulda matchers as documentation
[09:40:36] tbuehlmann: they are really good for that
[13:11:59] tbuehlmann: that's exactly that, just written as a string literal
[13:12:40] tbuehlmann: think this: how do you insert double quotes into a literal string using double quotes?

2018-09-19

[07:47:50] tbuehlmann: terens: when do you need it? when initializing a model?
[07:54:09] tbuehlmann: so we all agree callbacks aren't that great but you're simply not allowed to use alternatives. time to talk to your lead devs, nothing to be done here
[08:35:31] tbuehlmann: bijan_: as I'm using interactors I put them in app/interactors. app/services is fine as well
[12:06:59] tbuehlmann: dionysus69: credentials can save strings, so yes
[13:15:33] tbuehlmann: dionysus69: if it's really a secret and you're working with credentials, sure I guess

2018-09-17

[11:32:02] tbuehlmann: I couldn't tell
[13:13:59] tbuehlmann: apeiros: shouldn't that be just CORS? https://github.com/cyu/rack-cors
[13:37:39] tbuehlmann: CSP is for actually loading files, I'd say
[13:40:38] tbuehlmann: oh, right, that as well

2018-09-14

[05:59:01] tbuehlmann: sevenseacat: I failed the other day and went back to just yarn packages in my rails app :\
[10:13:18] tbuehlmann: I'd go with a interactor/service for sending messages, yes
[10:32:14] tbuehlmann: what does it do?
[10:34:55] tbuehlmann: I wouldn't place such a method in the controller. I'd either put it in the corresponding model or have an interactor/service for it
[10:37:39] tbuehlmann: start with a method in the model then
[11:01:38] tbuehlmann: sheepman: right, models should be named using the singular
[12:13:27] tbuehlmann: do you use the dotenv-rails or dotenv gem?
[12:17:18] tbuehlmann: then the .env will not be read from
[12:17:43] tbuehlmann: it's probably not
[12:19:34] tbuehlmann: PG_HOST might be set "outside" of your rails application and is therefore available inside the process
[12:19:48] tbuehlmann: right, or that
[12:25:25] tbuehlmann: it adds some juice like mentioned here: https://github.com/bkeepers/dotenv#note-on-load-order
[13:30:09] tbuehlmann: AndreYuhai: yup, it gets GCed if it's not referenced anymore
[14:06:31] tbuehlmann: charlielor: do you really need to manually load it?
[14:20:54] tbuehlmann: just add dotenv-rails to your Gemfile and you should be done
[14:38:58] tbuehlmann: charlielor: yes

2018-09-13

[11:48:46] tbuehlmann: no, you'll need to include ActiveModel::Validations into your class in order to use them
[12:20:10] tbuehlmann: can't you parse that json object into proper objects and validate these?
[12:25:17] tbuehlmann: sure, whatever floats your boat

2018-09-12

[09:18:08] tbuehlmann: morfin: exactly like that. haven't you tried?

2018-09-10

[12:25:29] tbuehlmann: pavelz: when using pry, you could call `$ some_object.some_method` and it will hopefully print some useful information

2018-09-07

[11:31:19] tbuehlmann: pama: works for me. how do you test it?
[11:34:27] tbuehlmann: maybe it's not caching? :)
[11:35:02] tbuehlmann: can you try this in a rails console? `ActiveRecord::Base.cache { SomeModel.first; SomeModel.first }`
[11:37:26] tbuehlmann: can you gist the code for this?
[11:37:32] tbuehlmann: and check the rails console thing?
[11:38:37] tbuehlmann: so chances are AR is not caching. can you gist your code?
[13:18:00] tbuehlmann: pama: the active record cache works per request, so it caches certain queries for a single request
[13:27:21] tbuehlmann: for which query exactly do you expect it?
[13:28:55] tbuehlmann: you also wouldn't do it that way, you'd include the company when fetching all orders, right?
[13:32:31] tbuehlmann: _now_ I see what you mean
[13:35:38] tbuehlmann: I can reproduce it and don't know why that is :)
[14:01:36] tbuehlmann: it just seems like the cache is disabled on the very first request after starting the server for whatever reason
[14:01:41] tbuehlmann: get to go now, happy coding

2018-09-06

[08:59:04] tbuehlmann: brotspinne: not without some headache, as it requires actionpack and activerecord 5.2
[10:22:54] tbuehlmann: that's a rails 6 feature, iirc
[12:17:50] tbuehlmann: kotepillar_: "id" is the conventional name for the primary key, is this your primary key?
[12:21:07] tbuehlmann: you can rename columns using rename_column: https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-rename_column
[12:21:15] tbuehlmann: this will change the table
[12:24:44] tbuehlmann: on an instance level this could just be: `def id; hello_id; end`
[12:25:13] tbuehlmann: I still assume this just being an example, you shouldn't override the id method

2018-08-31

[09:17:24] tbuehlmann: dionysus69: there's no local variable "price"
[10:44:39] tbuehlmann: ohai segmentation fault, long time no see \o/

2018-08-29

[06:54:44] tbuehlmann: baweaver: using a lambda/proc isn't the recommended way anymore, iirc. I think they changed to using methods, like here: https://github.com/rmosolgo/graphql-ruby/blob/fd8c87ab458921aa9d50c8ceb46c8be97e32cbfe/guides/getting_started.md#build-a-schema
[10:40:39] tbuehlmann: the public_file_server is disabled by default for production, so files from the public directory are not served. maybe that?
[10:46:12] tbuehlmann: in what directory (under app) is your image located and how do you reference it via image_tag?
[10:48:46] tbuehlmann: sunya7a: sounds good to me
[11:10:31] tbuehlmann: sunya7a: I was about mentioning it but the docs say it's valid to not have it :¿
[11:10:50] tbuehlmann: nope, I'm just blind, my bad

2018-08-22

[08:54:24] tbuehlmann: nemesit: yes. why do you want that, though?
[08:58:28] tbuehlmann: https://coderwall.com/p/wat2yw/haml-engine-render-scope
[09:12:34] tbuehlmann: now make it pretty

2018-08-16

[11:37:57] tbuehlmann: if it doesn't clutter up the controller too much, that's fine. I probably wouldn't do it in the model as some kind of callback
[13:06:53] tbuehlmann: recommending to buy more ram isn't that helpful, right?
[13:51:26] tbuehlmann: don't compare development and staging unless they are identical wrt setup

2018-08-15

[05:55:20] tbuehlmann: has joined #ruby
[05:55:26] tbuehlmann: has joined #RubyOnRails
[10:01:17] tbuehlmann: dminuoso: only via something like rack builder or router, iirc
[10:54:47] tbuehlmann: dminuoso: haven't used prometheus yet

2018-08-13

[08:14:18] tbuehlmann: can you gist what you have?
[08:24:54] tbuehlmann: okay, and what exactly is the error you're getting?
[08:26:22] tbuehlmann: your calculate_age method uses year_born, but the method doesn't know about it. so you could simply have a second method parameter for that and call the method like calculate_age(prompt, year_born)
[09:05:52] tbuehlmann: right, you can't do that
[09:42:16] tbuehlmann: dionysus69: a very simple approach: save the timestamp when a message got added and remove too old messages whenever you're adding to the array
[09:45:21] tbuehlmann: it's not in your hands then
[09:46:57] tbuehlmann: I think you're trying to fix browser memory behaviour which isn't in the scope of rails
[09:48:33] tbuehlmann: ever seen GC.start in javascript?
[19:25:20] tbuehlmann: *.net *.split

2018-08-10

[09:10:05] tbuehlmann: koichirose: shouldn't it be as easy as `Time.zone = …`?
[09:12:23] tbuehlmann: if you don't want to set it globally, how do you want to set it?

2018-08-09

[12:27:50] tbuehlmann: not sure I'd keep the caching in the model. I'd at least think about having it in the controller
[13:43:49] tbuehlmann: dionysus69: then at least rename the method so you don't forget it's caching
[13:55:49] tbuehlmann: sylario: you don't have to use such "service classes/objects", it just settled to be some useful thing
[14:01:33] tbuehlmann: ah, well, instance variables
[14:01:56] tbuehlmann: I want to memoize heavy calculations, and for that I use instance variables
[14:02:01] tbuehlmann: using class instance variables would be wrong

2018-08-06

[11:33:19] tbuehlmann: drale2k_: logging in using a different browser or device will not use the correct timezone. you should store the timezone in the database
[11:34:27] tbuehlmann: dionysus69: running a rake task spins up a rails application, a job backend already runs
[11:35:42] tbuehlmann: you could do that, sure
[11:36:41] tbuehlmann: if you don't trust your job backend's recurring jobs feature, you could still use rake and just schedule the job there
[11:42:39] tbuehlmann: it just needs the code and access to the database

2018-08-01

[09:38:32] tbuehlmann: dionysus69: are you looking for BigDecimal.new('0.1000000000000000001e1').to_s('F')?
[09:38:57] tbuehlmann: oh, badeball already suggested it, nvm

2018-07-31

[09:37:04] tbuehlmann: increasing Metrics/LineLength Max to 100 like a pro
[10:41:48] tbuehlmann: timwis: you probably want this? `User.belongs_to :rank` and `Rank.has_many :users, dependent: :nullify`
[10:42:22] tbuehlmann: this will nullify users.rank (which should be users.rank_id) when a rank is deleted
[10:53:49] tbuehlmann: the dependent option is used and ran in ruby-land when destroying a rank object
[11:16:32] tbuehlmann: I think having User#group_permissions is okay. if the query or scope is quite big, you could outsource that into a query object or something similar and simply use it in #group_permissions
[11:28:38] tbuehlmann: timwis: right, we don't need "get" and "set" in ruby. `user.group` is the getter and `user.group=` is the setter (if defined)
[14:34:06] tbuehlmann: timwis: use the raw sql for now and maybe refactor it into AR/arel later on

2018-07-28

[11:50:02] tbuehlmann: yottanami: do you use a model in an initializer?
[12:02:35] tbuehlmann: can you doublecheck? and can you gist the stacktrace?

2018-07-26

[11:27:15] tbuehlmann: mojtaba: what exactly was the typo? and can you gist the migration's code?
[11:35:32] tbuehlmann: the migration should've completed the first time. I'd roll that migration (including the typo) back, fix the typo and migrate again

2018-07-25

[08:29:36] tbuehlmann: cheeti: your application server and background job worker are different processes, so it's not that easy. one way would be to let the browser poll for updates and reload on a certain update. this could also happen via actioncable (websockets) or server sent events
[08:31:33] tbuehlmann: (are probably different processes*)
[10:42:55] tbuehlmann: garyserjj: unless you have good reason, use the regular id
[10:50:35] tbuehlmann: so there's an admin and regular users?
[10:53:48] tbuehlmann: regarding the id issue: if you don't want people to see increasing id numbers so they can't assume the size of your data, just switch from using bigints to uuids

2018-07-24

[07:05:58] tbuehlmann: have an evil_ruby column and save a string in it, that'll be evaled later on in ruby-land
[07:06:04] tbuehlmann: yes, I just wrote that
[07:06:31] tbuehlmann: not okay actually
[07:06:45] tbuehlmann: there's hopefully a better solution to your problem
[07:12:43] tbuehlmann: why not just have that code in your application? am I missing something?
[07:13:57] tbuehlmann: I guess it's cool to have these things in your application and if you're ever at a point where you feel there's missing an abstraction, think again
[08:17:48] tbuehlmann: surprised my irc client correctly displays the thumb up

2018-07-20

[00:07:05] tbuehlmann: *.net *.split
[00:15:29] tbuehlmann: has joined #RubyOnRails
[00:15:50] tbuehlmann: has joined #ruby
[09:12:54] tbuehlmann: conta: kind of
[09:13:58] tbuehlmann: when having js-enabled capybara tests (or feature specs in rspec), you needed a database rewinder/cleaner in the past, since the server and your test didn't share the same database connection. that's fixed for system tests (and system specs in rspec) for newer rails versions
[09:14:24] tbuehlmann: this officially only works for system tests, but will also work for everything else
[09:16:44] tbuehlmann: conta: so, "yes", you probably don't need a database rewinder/cleaner anymore
[09:18:41] tbuehlmann: https://github.com/tbuehlmann/til/blob/master/rails/transactional-tests.md
[10:52:59] tbuehlmann: NL3limin4t0r: there's also `Bar < Foo # => true`
[12:47:36] tbuehlmann: mensvaga: could be $ bundle gem a-b-c

2018-07-18

2018-07-16

[07:50:40] tbuehlmann: https://i.imgur.com/CDqD1KV.jpg
[12:21:55] tbuehlmann: no idea, but… is spring running?