tbuehlmann_

Activity Graph

Page 1 of 1

2017-09-08

[22:08:08] tbuehlmann_: Ping timeout: 240 seconds

2017-09-07

[09:24:03] tbuehlmann_: .where(type: SomeClass).inspect raises a TypeError whereas .where(type: "SomeClass") doesn't
[09:24:17] tbuehlmann_: the generated SQL is the same though
[09:36:13] tbuehlmann_: cheeti: can you gist the controller?
[09:51:12] tbuehlmann_: can you add the exact error message?
[09:51:43] tbuehlmann_: yeah, that's what I assume as well
[09:52:25] tbuehlmann_: yes, if you insist

2017-09-06

[05:56:32] tbuehlmann_: so, bootstrap 4 forms understand the concept of "was-validated", applying styles to the form when the form contents were validated. I don't really want to add an css class to the form in case of request.post?, but rather when the underlying model really was validated (as in: #save or #valid? was called). there's no such thing as asking the object whether it was validated, right?
[07:07:53] tbuehlmann_: dminuoso: what do the cool kids use these days?
[07:46:02] tbuehlmann_: thanks for the input btw
[13:29:20] tbuehlmann_: crst: why's there a space?
[18:01:45] tbuehlmann_: FrostCandy: it compares uri.scheme and "https", returning either false or true
[18:02:03] tbuehlmann_: so it sets req_options = {use_ssl: true}

2017-09-05

[07:31:29] tbuehlmann_: crst: sounds like your apache isn't serving them?
[07:33:00] tbuehlmann_: nope, but I'm sure the interwebz has
[07:38:08] tbuehlmann_: xco: can you prepare a minimal reproduction app that we can inspect?
[07:50:11] tbuehlmann_: maryo: I don't get the question yet. what's the problem? can you share some code?
[09:23:02] tbuehlmann_: sathish: it depends on the method. what does it do exactly?
[09:26:05] tbuehlmann_: okay, great, you could make it a scope then
[09:26:38] tbuehlmann_: that scope would query for records having that condition
[09:28:35] tbuehlmann_: sathish: sure, you can do that
[09:37:47] tbuehlmann_: sathish: yeah, exactly

2017-09-04

[07:11:43] tbuehlmann_: xco: maybe this? https://github.com/blowmage/minitest-rails/issues/185
[14:09:27] tbuehlmann_: dminuoso: big company oracle problem, eh? :)
[16:38:17] tbuehlmann_: FrostCandy: I'm seeing this for the first time. are you sure you can set the session like that?
[17:51:12] tbuehlmann_: xco: have you checked the link I pasted hours ago?

2017-09-01

[11:07:13] tbuehlmann_: crst: what do you need?
[11:35:56] tbuehlmann_: crst: belongs_to is an alias to references
[11:59:00] tbuehlmann_: crst: that would be two migrations, right?
[11:59:44] tbuehlmann_: crst: I just use whatever `bin/rails generate model child parent:belongs_to` generates in the migration
[12:04:04] tbuehlmann_: yes, the migration is only responsible for setting up the tables and indices correctly
[12:19:44] tbuehlmann_: crst: what data is that?
[18:33:40] tbuehlmann_: Maakuth: have an example of your problem?

2017-08-30

[07:51:57] tbuehlmann_: has joined #ruby
[09:06:18] tbuehlmann_: dionysus69: I wrote an example application for what I guess is what you want (but having has_many and not has_one): https://github.com/tbuehlmann/has-many-through-selection
[09:06:31] tbuehlmann_: might help, maybe not
[09:14:29] tbuehlmann_: parent belongs to child and child has_many parents sounds weird
[09:22:12] tbuehlmann_: so an user creates an evaluation? sounds like a standard scenario to me
[09:44:32] tbuehlmann_: Knickelbach_: there are more than one intention when using bang methods. they can identity as a dangerous method, or, when having a non-bang version as well, as a mutating method
[09:45:32] tbuehlmann_: string.capitalize will return a new (capitalized) string object. string.capitalize! will return the same object, it being changed/mutated

2017-08-29

[09:43:24] tbuehlmann_: dionysus69: you're still on this problem? why didn't you just switch the lines as suggested?
[09:58:37] tbuehlmann_: you are kidding me, right? I suggested this twice :p
[10:53:21] tbuehlmann_: this is not a website, you can't browse it that way
[10:54:29] tbuehlmann_: they may be interfaces for redis, but it doesn't work that way

2017-08-28

[15:24:06] tbuehlmann_: dionysus69: can you gist your config/routes.rb file?
[15:32:19] tbuehlmann_: line 7 has precedence over line 8, just switch them
[16:16:41] tbuehlmann_: zinefer: you could play with relation.order_values

2017-08-27

[12:32:24] tbuehlmann_: jdeen: I don't get the question
[13:16:01] tbuehlmann_: jdeen: well, the domain has to point to your host
[13:16:30] tbuehlmann_: what setup do you have? do you use nginx/apache as a reverse proxy? or is it just your rails application server (puma/unicorn/thin/...)?
[13:17:16] tbuehlmann_: then you have to tell nginx to proxy/upstream the request to the correct app, as in "allowing" the subdomain

2017-08-26

[07:12:14] tbuehlmann_: crst: what are you trying to do?
[07:38:52] tbuehlmann_: crst: you could just write it in your html response

2017-08-25

[07:54:04] tbuehlmann_: crst: can you gist your models?
[09:37:49] tbuehlmann_: you could call your_model.increment(:attribute, 42)
[09:46:04] tbuehlmann_: crst: can you gist your code and the error message?
[09:48:09] tbuehlmann_: Shilon: you can also call your_model.attribute += 42, but that only works if attribute is already a number
[09:53:45] tbuehlmann_: crst: no, I wouldn't. permissions shouldn't be part of the user model
[09:54:37] tbuehlmann_: I like the pundit gem, which has policies for managing authorization
[09:56:06] tbuehlmann_: similar in that they both try to solve authorization, yeah
[11:24:52] tbuehlmann_: Shilon: sure. what problem do you face right now?
[11:26:59] tbuehlmann_: and the progress is supposed to be invitations_used divided by invitations_limit?
[11:34:14] tbuehlmann_: so this is the answer then? just use invitations_used/invitations_limit as the progress %
[11:38:19] tbuehlmann_: maybe turn integers to float or something, code would surely help

2017-08-24

[12:20:04] tbuehlmann_: zmo: so params[:foo] seems to be '42' and not a hash. why's that?
[12:22:58] tbuehlmann_: it should be params.require(:foo).permit(:bar, :baz, …) if you're having "default" forms
[12:23:22] tbuehlmann_: if you don't have the model namespace it's just params.permit(:foo, …)
[12:27:28] tbuehlmann_: let's say you have a project with a name and a priority, then the params should look like {project: {name: 'some name', priority: '5'}} and you would permit attribute like params.require(:project).permit(:name, :priority))
[12:29:11] tbuehlmann_: I personally would add it
[12:30:53] tbuehlmann_: zmo: rails does this for you when using the right form helpers
[12:42:36] tbuehlmann_: zmo: that's autogenerated, coming from config/routes.rb
[12:43:30] tbuehlmann_: zmo: so when creating/updating a model, you can use <%= form_for(@somemodelinstance) do |f| %> and add fields like <%= f.text_field :bar %>
[12:43:53] tbuehlmann_: I suggest having a look at http://guides.rubyonrails.org/getting_started.html, there are a lot of common things explained
[16:43:12] tbuehlmann_: dionysus69: do you want single table inheritance?

2017-08-16

[11:27:03] tbuehlmann_: kitsuneyo: there might be a better one, but this comes to my mind first: array.each_with_object({}) { |item, hash| hash[item.to_sym] = object.public_send(item) }

2017-08-15

[10:53:38] tbuehlmann_: Takumo: what version of rails?
[10:55:08] tbuehlmann_: try adding the inverse_of option on both sides of the association then
[10:57:22] tbuehlmann_: see http://guides.rubyonrails.org/v4.2/association_basics.html#bi-directional-associations

2017-08-14

[13:04:22] tbuehlmann_: digitalowl: I'm rather a pundit guy, but let's give it a shot
[13:08:23] tbuehlmann_: before I go into detail: do you use cancan or cancancan?
[13:15:25] tbuehlmann_: I suggest using cancancan instead, this may solve one problem or another
[13:19:56] tbuehlmann_: digitalowl: okay. what's the association between user and books? Book.belongs_to :user?
[13:22:26] tbuehlmann_: I think you have to use a block then: https://github.com/ryanb/cancan/wiki/Defining-Abilities-with-Blocks
[13:27:47] tbuehlmann_: I did, but it's been years
[13:38:54] tbuehlmann_: in ember land?
[13:43:30] tbuehlmann_: oh, the JSON response is the one from your third party api, right?
[13:45:42] tbuehlmann_: pseudo: response['cars'].map { |car_attributes| Car.new(car_attributes) }
[13:48:01] tbuehlmann_: I made some assumptions, but yeah, response['cars'] being an array of car attribute hashes, then just map them using Car.new
[13:49:03] tbuehlmann_: I thought they are databaseless and you wouldn't store them?
[13:49:10] tbuehlmann_: oh, just `@cars = …`
[16:24:53] tbuehlmann_: et09: you can establish the connection in the models by calling `establish_connection(:some_name)` in them
[16:25:05] tbuehlmann_: some_name being the key used in the config/database.yml
[16:45:55] tbuehlmann_: why the execute? you should be able to just use the models

2017-08-11

[16:26:13] tbuehlmann_: dretnx: shopify does 80k r/s, not sure if that is large traffic?

2017-08-10

[08:48:16] tbuehlmann_: Terens: what's the usecase?
[08:54:05] tbuehlmann_: and you need rabbitmq for that?
[10:22:36] tbuehlmann_: you're using the wrong param name and therefore the wrong model method. try translations_attributes instead of translations
[10:24:09] tbuehlmann_: also, I think the data structure should be a hash and not an array
[10:40:39] tbuehlmann_: dionysus69: have you added the lib/ directory to your autoload_paths or eager_load_paths?
[10:43:47] tbuehlmann_: can you gist the validator and the models and the error?
[13:02:41] tbuehlmann_: dionysus69: so the file is not named after the constant in it?
[13:05:00] tbuehlmann_: I'd put them in different files to lib/
[13:05:34] tbuehlmann_: you shouldn't need to require them then

2017-08-09

[09:17:10] tbuehlmann_: you should only use the latter, because the user might change the form inputs
[09:59:45] tbuehlmann_: jarr0dsz: what does a dynamic model does?
[10:01:12] tbuehlmann_: you could use serialized columns or hstore with postgres for some datastructures, or build an EAV model with AR classes yourself

2017-08-08

[09:48:12] tbuehlmann_: dionysus69: rails can cache things, see http://guides.rubyonrails.org/caching_with_rails.html
[10:08:00] tbuehlmann_: fugee: either adapt the user_params method so the values depend on the role that is doing an update, or simply have an additional Admin::UsersController instead
[10:12:01] tbuehlmann_: fugee: I don't understand the problem then
[10:13:12] tbuehlmann_: users controller, by having an user_params method
[10:13:37] tbuehlmann_: that's also the default in a scaffolded controller
[10:14:19] tbuehlmann_: there shouldn't be any param whitelisting in the application controller

2017-08-07

[11:50:08] tbuehlmann_: actioncable connections don't block a puma thread in order to work, so that shouldn't be it. but having database connections being checked out, that's quite possible
[11:50:52] tbuehlmann_: you are responsible for ensuring the connections are checked in again after every channel action, iirc
[11:51:05] tbuehlmann_: this might have changed, but that's what was happening some months ago
[12:02:37] tbuehlmann_: https://github.com/rails/rails/issues/23778
[12:02:55] tbuehlmann_: that's what I had in mind
[18:19:13] tbuehlmann_: cjohnson: you could also use a counter cache column and check parent.children_count == 0, that way the database doesn't have to be queried a second time

2017-08-04

[10:05:00] tbuehlmann_: xpl0iter: do you have a validation for this?
[10:06:29] tbuehlmann_: rails doesn't add errors for database constraints, only for "soft" validations from your model. so just add a validation in your model

2017-08-03

[10:09:16] tbuehlmann_: adgtl: it doesn't have to be redis, but you need some kind of shared pub/sub, and the async/in-memory adapter doesn't work when having more than one webserver process or thread
[10:48:32] tbuehlmann_: it's a blocking call, so it blocks
[10:57:41] tbuehlmann_: noob_on_rails: my take on this is to not have ember and rails in one project but having two separate projects
[10:58:51] tbuehlmann_: I don't know what you mean by proxy, but simply have two projects, running on different ports
[11:01:32] tbuehlmann_: I can't argue with your senior ¯\_(ツ)_/¯

2017-08-01

[09:43:45] tbuehlmann_: krmela: I don't understand the question. what are your models and what columns do they have?
[10:03:02] tbuehlmann_: and what's the problem?
[10:24:16] tbuehlmann_: isn't that a completely unrelated issue?
[10:30:25] tbuehlmann_: sorry, I can't follow you
[10:41:04] tbuehlmann_: xhoy: what rails version are you on?
[10:41:35] tbuehlmann_: try adding the inverse_of option to the associations
[10:43:03] tbuehlmann_: well, is it a problem for you?
[10:49:09] tbuehlmann_: you're welcome!
[11:23:09] tbuehlmann_: xhoy: it's the default
[11:55:48] tbuehlmann_: use rails 5? :)

2017-07-31

[15:56:43] tbuehlmann_: sekmo: yes, there is: https://github.com/plataformatec/devise#controller-filters-and-helpers

2017-07-30

[11:15:59] tbuehlmann_: aldnav: find out where all_references is defined and check what object the method returns. this object responds to the #users method
[11:16:10] tbuehlmann_: ph88: can you gist your controller?
[11:22:06] tbuehlmann_: right. you can see in line 69 that the method returns `extractor`, which is a Gitlab::ReferenceExtractor
[11:33:21] tbuehlmann_: that one is a bit tricky
[11:33:39] tbuehlmann_: https://gitlab.com/gitlab-org/gitlab-ce/blob/4c89929fb4211aa1cf5f311a0cec89988de45184/lib/gitlab/reference_extractor.rb#L28-32 defines the users method
[11:49:52] tbuehlmann_: aldnav: you're welcome

2017-07-29

[08:29:20] tbuehlmann_: the test code usually stays in the app
[08:30:54] tbuehlmann_: what exactly is this util stuff?
[08:31:24] tbuehlmann_: like fixtures? they also stay in the app
[08:32:22] tbuehlmann_: ams__: some rake tasks are disabled for production nowadays, maybe do that too
[08:38:35] tbuehlmann_: ams__: if they are rake tasks, you can use `check_protected_environments`
[08:38:44] tbuehlmann_: like this: https://github.com/rails/rails/pull/24399/files#diff-28a5ae383b291583c513ad8eeed99a3aR259
[08:41:37] tbuehlmann_: that's highly unusual. I'd definitively keep the test code in the app
[08:43:00] tbuehlmann_: you're welcome
[10:47:57] tbuehlmann_: yunior_alayo: can you show the code?
[10:52:47] tbuehlmann_: I can't help you without you showing the code and the stacktrace
[10:57:44] tbuehlmann_: can you gist the mailer file and the error you get?
[10:57:54] tbuehlmann_: with a complete stacktrace
[11:01:40] tbuehlmann_: and how do you call it? and where's the stacktrace?
[11:10:01] tbuehlmann_: how do you call the mailer? you haven't shown yet
[11:13:31] tbuehlmann_: gist what you do
[11:14:31] tbuehlmann_: do you instantiate the mailer? that's not how you do it
[11:14:56] tbuehlmann_: try ProfileRegistrationNotifierMailer.error_mail.deliver_now
[11:18:23] tbuehlmann_: I don't know then. create a minimal reproduction app and let's see
[16:29:16] tbuehlmann_: kitallis: what's a domain config?
[16:29:54] tbuehlmann_: I don't know what that is. do you have an example?
[16:32:59] tbuehlmann_: if `config` is coming from Rails.configuration, then no, I don't know of any hot reloading (in production)

2017-07-27

[07:35:55] tbuehlmann_: Quintasan: if there's no action, rails will assume there is an empty method for it
[18:18:09] tbuehlmann_: dionysus69: it's probably because you're on the create action and not the new action?
[18:48:01] tbuehlmann_: jglauche: why do you name your controllers singular?
[18:51:32] tbuehlmann_: can you gist your routes.rb?
[18:53:55] tbuehlmann_: well, you normally use plural controller names and plural route names when using .resources
[18:54:30] tbuehlmann_: when you have singular routes, probably like cart, use singular route names (`resource :cart`) and plural controller names
[18:54:45] tbuehlmann_: basically always plural controller names
[19:17:35] tbuehlmann_: jglauche: no idea
[19:36:03] tbuehlmann_: cam27: search for the i18n translation in the project and then look it up in the code

2017-07-26

[07:22:56] tbuehlmann_: testercsgo: what exactly do you want to validate?
[07:27:43] tbuehlmann_: sounds like a custom validation to me
[09:38:07] tbuehlmann_: spami: is build(:test_automation_copycat, test_hash: nil) active?
[15:19:19] tbuehlmann_: ElektroBug: so a blog/tutorial/project belongs to a category?
[15:21:24] tbuehlmann_: I'd probably go with a porlymorphic association, see http://guides.rubyonrails.org/association_basics.html#polymorphic-associations
[15:25:27] tbuehlmann_: oh, I might have been a bit hasty here
[15:26:42] tbuehlmann_: you could have category_id columns on each of the models, that'd be easy
[19:44:50] tbuehlmann_: tycoon177: I have something for you: https://github.com/tbuehlmann/has-many-through-selection

2017-07-24

[17:45:56] tbuehlmann_: ali_g: check for search.present? instead of just search
[17:46:30] tbuehlmann_: cagomez: if you want the developers of your application to use forman, you should add it to the Gemfile
[17:52:52] tbuehlmann_: a sidenote: last(...) will return an array, whereas where(...) will return a relation
[19:09:49] tbuehlmann_: well, 'date' is not blank?, that's why .all?(&:blank?) returns false
[19:10:35] tbuehlmann_: if you want any, then use .any?
[19:10:39] tbuehlmann_: .all? checks for _all_

2017-07-22

[11:42:14] tbuehlmann_: zhjwpku[m]: welcome!

2017-07-20

[12:24:54] tbuehlmann_: sign_in can only be used in before/after and it methods
[12:25:06] tbuehlmann_: maybe more, but not in describe/context
[12:43:02] tbuehlmann_: berenhap: for json requests this is the default, iirc
[12:43:38] tbuehlmann_: you can turn it off if you want: http://api.rubyonrails.org/classes/ActionController/ParamsWrapper/ClassMethods.html#method-i-wrap_parameters
[12:49:54] tbuehlmann_: berenhap: yep, just call the method only in the controller you want to change the behaviour
[12:52:57] tbuehlmann_: you can just call it in your class, no need for a before_action
[13:22:24] tbuehlmann_: garge hydron collidor?

2017-07-19

[09:33:55] tbuehlmann_: krmela: I remember the case. so I would have checkboxes representing dayoffers instead of foods. I would have WeekDay.accepts_nested_attributes_for :dayoffers and use fields_for in the form to display one checkbox per dayoffer. and I would reject the ones not being selected
[09:40:36] tbuehlmann_: I wouldn't do it that way
[09:45:17] tbuehlmann_: I would create an array of dayoffers for each food. if there's a dayoffer already existing for a food for the week_day, use that. if not, build a new one. so you end up having one array with n dayoffers (when there are n foods)
[09:46:25] tbuehlmann_: when using accepts_nested_attributes_for, you can create/update a week_day like week_day.update(dayoffers_attributes: {…})
[09:46:46] tbuehlmann_: see http://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html#method-i-accepts_nested_attributes_for
[09:46:58] tbuehlmann_: and http://api.rubyonrails.org/classes/ActionView/Helpers/FormBuilder.html#method-i-fields_for
[09:51:32] tbuehlmann_: if that's easier for you, sure
[09:53:20] tbuehlmann_: what's not working with your idea?
[09:55:13] tbuehlmann_: week_day.food_ids = […] should work actually
[09:59:05] tbuehlmann_: what is the exact error?
[10:07:17] tbuehlmann_: no idea. setup pry and debug it
[16:39:17] tbuehlmann_: you don't _need_ it
[16:39:22] tbuehlmann_: my setup is rspec with database_rewinder

2017-07-18

[07:13:49] tbuehlmann_: has joined #RubyOnRails
[10:28:05] tbuehlmann_: krmela: so you want all associated dayoffers for one specific weekday and then all not associated dayoffers for that same weekday?
[10:30:51] tbuehlmann_: I don't understand the connection to Food yet. can you gist your models and their associations?
[10:36:29] tbuehlmann_: still not sure I understand. for a given week_day you want to get what exactly?
[10:38:59] tbuehlmann_: ah, I see. will prepare a gist
[10:40:30] tbuehlmann_: https://gist.github.com/tbuehlmann/db14f7aab4d0cdc01a37f14686156612#file-week_day-rb-L3
[10:40:40] tbuehlmann_: that way you can call week_day.foods
[10:43:44] tbuehlmann_: you could write a clever join condition, but I'm too lazy for that right now. this could work: Food.where.not(id: week_day.foods.select(:id))
[10:52:38] tbuehlmann_: glad to be of help
[13:20:08] tbuehlmann_: ule: who says passing a hash is bad practice?
[13:20:52] tbuehlmann_: that's basically how activemodel and activerecord objects work. are you sure the senior doesn't mean something else?
[13:22:22] tbuehlmann_: are you really really sure? maybe the senior means to not throw the raw params into the method call rather than using strong params?
[13:23:18] tbuehlmann_: right, that's sounds correct to me
[13:23:38] tbuehlmann_: I prefer this way over having an explicit order of the single attributes
[13:24:03] tbuehlmann_: what if you _don't_ want to update a single one of the attributes? providing nil obviously doesn't work
[13:24:57] tbuehlmann_: that is a common rails practice, you can quote me on this
[13:29:45] tbuehlmann_: I'm glad you asked

2013-09-26

[13:09:54] tbuehlmann_: http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#method-i-pluralize
[13:10:32] tbuehlmann_: but I'd also stick to i18n
[13:17:34] tbuehlmann_: there's a difference between class methods and scopes. I personally tend to use scopes, because I'm lazy. using a class method, you might have to think of an "else" branch and return .none
[13:18:19] tbuehlmann_: of course not, but these two aren't identical
[13:18:52] tbuehlmann_: wouldn't call it fancy, but that's the essence
[13:19:52] tbuehlmann_: http://blog.plataformatec.com.br/2013/02/active-record-scopes-vs-class-methods/ sums it up pretty good
[13:29:12] tbuehlmann_: you might want User.where('integer > ?', 100)