« Back to channel list

#RubyOnRails - 11 January 2019

« Back 1 day Forward 1 day »
[00:25:01] tdy: has joined #RubyOnRails
[00:38:52] chouhoulis: has joined #RubyOnRails
[00:42:35] lexileo: has joined #RubyOnRails
[01:05:29] IGnorAND: Boxer has_many fights. I want to create a function that returns his last fight, I have @boxer.fights.order(match_date: :desc).first.match_date, but now I'd like a list of boxers with their last fight date, This however seems to run a query for every boxer when I think it could be done in 1 query. Am I mistaken?
[01:12:45] orbyt_: has joined #RubyOnRails
[01:37:23] EXCHGR: has joined #RubyOnRails
[01:50:42] Tempesta: has joined #RubyOnRails
[02:03:36] Saukk: has joined #RubyOnRails
[02:07:42] Linuus: has joined #RubyOnRails
[02:11:35] tdy: has joined #RubyOnRails
[02:30:50] chouhoulis: has joined #RubyOnRails
[02:33:57] orbyt_: has joined #RubyOnRails
[02:41:39] ebsen: has joined #RubyOnRails
[02:59:41] Linuus: has joined #RubyOnRails
[03:19:41] uplime: has joined #RubyOnRails
[03:21:40] orbyt_: has joined #RubyOnRails
[03:22:38] ariedler: has joined #RubyOnRails
[03:26:45] duderonomy: has joined #RubyOnRails
[04:09:29] braincrash: has joined #RubyOnRails
[04:20:35] kapil____: has joined #RubyOnRails
[04:24:49] DTZUZO: has joined #RubyOnRails
[04:27:58] ur5us: has joined #RubyOnRails
[04:56:07] gambl0re: has joined #RubyOnRails
[05:05:14] Linuus: has joined #RubyOnRails
[05:15:02] DTZUZO: has joined #RubyOnRails
[05:23:29] ariedler: has joined #RubyOnRails
[05:51:38] orbyt_: has joined #RubyOnRails
[06:23:57] conta: has joined #RubyOnRails
[06:47:26] tdy: has joined #RubyOnRails
[06:54:45] sevenseacat: has joined #RubyOnRails
[06:56:36] KeyJoo: has joined #RubyOnRails
[07:13:44] dionysus69: has joined #RubyOnRails
[07:24:07] ariedler: has joined #RubyOnRails
[07:31:14] Linuus: has joined #RubyOnRails
[07:41:09] fox_mulder_cp: IGnorAND @boxer - instance. Boxer.all.order(..) is a list of ordered via your criterias
[07:48:29] orbyt_: has joined #RubyOnRails
[07:53:51] benlieb: has joined #RubyOnRails
[07:58:42] jenrzzz: has joined #RubyOnRails
[08:08:28] status402: has joined #RubyOnRails
[08:12:32] status402: has joined #RubyOnRails
[08:14:27] reber: has joined #RubyOnRails
[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
[08:23:20] status402: has joined #RubyOnRails
[08:42:16] conta: has joined #RubyOnRails
[08:50:40] mikecmpbll: has joined #RubyOnRails
[08:58:50] jenrzzz: has joined #RubyOnRails
[09:05:41] zululee_: has joined #RubyOnRails
[09:06:23] Ergo: has joined #RubyOnRails
[09:07:06] mikecmpbll: has joined #RubyOnRails
[09:16:31] jlebrech: has joined #RubyOnRails
[09:17:09] uplime: has joined #RubyOnRails
[09:18:15] jlebrech: is there a nicer way to do this? <div v-for="c in <%= @contexts.to_json %>"> this is cool https://github.com/gazay/gon but another gem for this is overkill.
[09:20:54] hahuang65: has joined #RubyOnRails
[09:27:41] hahuang65: has joined #RubyOnRails
[09:29:41] srinidhi: has joined #RubyOnRails
[09:34:51] mikecmpb_: has joined #RubyOnRails
[09:40:47] jlebrech: has joined #RubyOnRails
[09:43:40] gregf_: has joined #RubyOnRails
[09:56:37] KeyJoo: has joined #RubyOnRails
[09:59:30] jenrzzz: has joined #RubyOnRails
[10:01:39] Linuus: has joined #RubyOnRails
[10:04:08] DTZUZO: has joined #RubyOnRails
[10:05:04] Spaceman77: has joined #RubyOnRails
[10:05:43] Spaceman77: I'm having an issue with rails' asset pipeline. I have some haml templates that i need compiled as html
[10:06:15] Spaceman77: I managed to do this by using Sprockets.register_engine
[10:07:10] Spaceman77: But after i changed some app settings, it doesn't work anymore
[10:07:14] Spaceman77: even after reverting the changes
[10:07:26] bikram_: has joined #RubyOnRails
[10:08:48] Spaceman77: what the heck
[10:09:04] Spaceman77: rails takes my haml files, compiles them to html, and leaves the extension as .haml
[10:11:41] tbuehlmann: Spaceman77: is this about regular view rendering?
[10:13:04] za1b1tsu: has joined #RubyOnRails
[10:14:39] Spaceman77: No, i need to precompile some assets(error pages)
[10:15:10] Spaceman77: I need localisation support and stylesheets, even when rails is broken
[10:15:21] Spaceman77: so i have hooked into the precompilation process
[10:16:00] Spaceman77: and i generate the error page views whenever i precompile
[10:17:24] Arkentias: has joined #RubyOnRails
[10:19:03] Arkentias: Hey guys! I have a resource with a nested route like so resources :procedures do
[10:19:04] Arkentias: post :execute
[10:19:17] Arkentias: (new line after "like so")
[10:19:39] Arkentias: I want to be able to do a post on a specific procedure, hence the "post :execute"
[10:20:12] Arkentias: The problem is that for all the routes of the resource, the id params is called :id, but for "post :execute", it's called :procedure_id
[10:20:48] Arkentias: I know this is the normal behaviour but I'd like to be able to use the same "set_procedure" method for both use cases in my controller, any idea? Should I just check for the existence of :id & :procedure_id ?
[10:22:18] jenrzzz: has joined #RubyOnRails
[10:24:11] tbuehlmann: Arkentias: haven't seen that before but could reproduce. adding `, on: :member` helps, though
[10:25:16] drale2k_: has joined #RubyOnRails
[10:27:00] Spaceman77: Rails adds wrong file extension for precompiled assets, help :(
[10:29:06] Arkentias: tbuehlmann Thanks a lot! Looks perfect now :)
[10:37:26] Arkentias: Spaceman77 I think a lot of people would be happy to help you but you're not really giving any information regarding your problem
[10:38:47] catbusters: has joined #RubyOnRails
[10:43:11] za1b1tsu: has joined #RubyOnRails
[10:44:29] catbusters: I have an action in one of my controllers wherein I want to perform an external API call over the network and return the result of that to the client
[10:44:33] catbusters: Something like this: https://dpaste.de/8Wg4#L
[10:45:33] catbusters: However due to the single-threaded and sync nature of ruby this blocks the entire server from responding to any other requests in the meantime, pages don't load, api calls don't go through, etc.
[10:47:13] catbusters: What can I do to work around this? I've seen people recommend moving the API call to a background job and polling the server from the client for updates, but that solution seems suboptimal
[10:50:09] wethu: has joined #RubyOnRails
[10:54:26] tbuehlmann: catbusters: you should have a higher concurrency than 1 either way
[10:55:10] catbusters: tbuehlmann: Yes, that's the plan. Ruby processes = number of cores is what's used right?
[10:55:47] tbuehlmann: something like that, yes. it might differ per app, though
[10:58:19] catbusters: tbuehlmann: Alright. Even in that case though, 1 request will block an entire process
[10:58:39] catbusters: Is there any way in which say I could handle the request async like Node?
[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:01:50] nertzy: has joined #RubyOnRails
[11:07:10] catbusters: Okay I'll test that out
[11:07:38] catbusters: Do there happen to be any conventions around making API calls from inside controllers maybe?
[11:09:37] jenrzzz: has joined #RubyOnRails
[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:17:53] drale2k_: has joined #RubyOnRails
[11:22:21] jenrzzz: has joined #RubyOnRails
[11:25:34] ariedler: has joined #RubyOnRails
[11:27:18] catbusters: Alright thanks for the help tbuehlmann :)
[11:34:34] jenrzzz: has joined #RubyOnRails
[11:38:54] tbuehlmann: you're welcome!
[11:43:19] jenrzzz: has joined #RubyOnRails
[11:47:14] uplime: has joined #RubyOnRails
[11:48:08] deathwishdave: has joined #RubyOnRails
[11:48:24] deathwishdave: good morning one and all!
[11:50:01] deathwishdave: I am looking for a rails app that can handle registration, licensing, authentication etc for a desktop application
[11:50:45] deathwishdave: anyone know if such a thing exists? I guess i'm not google the right terms
[11:55:06] ariedler: has joined #RubyOnRails
[11:55:39] status402_: has joined #RubyOnRails
[11:59:35] jenrzzz: has joined #RubyOnRails
[12:05:10] catbusters: deathwishdave: Registration and authentication can be handled by any Rails application (you might want to look up devise)
[12:05:16] catbusters: Can you expand on the licensing part?
[12:07:34] deathwishdave: the process... Account manager receives email invite, they invite their team to create accounts, once created, team can enter their details into desktop application to activate it.
[12:08:07] deathwishdave: other requirements include grace periods, software calling home, reserved licences etc
[12:13:52] catbusters: Maybe someone else can correct me, but this sounds like something you'll need to code yourself, not aware of any readymade Gems for this
[12:14:32] deathwishdave: catbusters coming to this conclusion myself, thanks
[12:20:36] IGnorAND: tbuehlmann: thanks, I'll try it
[12:26:57] deathwishdave: has joined #RubyOnRails
[12:28:54] jenrzzz: has joined #RubyOnRails
[12:30:49] Linuus: has joined #RubyOnRails
[12:43:46] Jervis_: has joined #RubyOnRails
[12:45:41] jenrzzz: has joined #RubyOnRails
[12:50:46] uplime: has joined #RubyOnRails
[12:54:41] jenrzzz: has joined #RubyOnRails
[13:01:59] jenrzzz: has joined #RubyOnRails
[13:11:19] reber: has joined #RubyOnRails
[13:12:54] jenrzzz: has joined #RubyOnRails
[13:14:00] Arkentias: has joined #RubyOnRails
[13:16:24] srinidhi: has joined #RubyOnRails
[13:16:30] Arkentias: Hey again guys, I have this in my model's initialize method but everytime I try to accept my @ variable in my instance methods, it's nil. Any insight?
[13:16:31] Arkentias: def initialize(options = nil)
[13:16:32] Arkentias: super(options)
[13:16:32] Arkentias: @model_errors = []
[13:17:38] Arkentias: I'm supposed to be able to access @model_errors in all my instance methods right?
[13:20:46] status402: has joined #RubyOnRails
[13:25:41] tbuehlmann: Arkaniad: it this an active record model?
[13:26:03] Arkentias: Ah oups not me
[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:27:25] Arkentias: Yes but in fact "model_errors" is an array in which I put errors from other models that i'm validating, weird use case but those are errors from elsewhere
[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:29:41] Arkentias: No they are not especially. Long story short this object receives a big payload describing objects to create that can be any of the Models in my application. It validates them and returns the array of errors if there is a single one, if not it will persist them all to the DB
[13:30:26] Arkentias: The business logic is pretty intricate but I'm just trying to find out why those hecking instance variables are nil even from the class itself
[13:31:37] Arkentias: I'm doing Object.find then calling Object.do_something and the @ variables are nul in the do_something method. Initialize is called everytime you instantiate an object right?
[13:32:40] drale2k_: has joined #RubyOnRails
[13:38:44] Arkentias: OK turns out initialize isn't called everytime an object is instantiated in fact
[13:39:10] jenrzzz: has joined #RubyOnRails
[13:39:11] Arkentias: Used after_initialize callback instead!
[13:39:29] alexterziev: has joined #RubyOnRails
[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:40:03] Arkentias: Ah yeah works too indeed!
[13:41:19] Arkentias: Thanks for your assistance!
[13:41:49] tbuehlmann: you're welcome!
[13:41:56] alexterziev: Hi, after updating rails from version 4.2 to 5.2, I get error in registering new users. The error comes from Member model when it executes 'create' function. Here is the full error stack trace: https://pastebin.com/xabxUUkL
[13:42:47] tbuehlmann: alexterziev: what's in app/controllers/sessions_controller.rb:30?
[13:43:08] eddof13: has joined #RubyOnRails
[13:43:57] alexterziev: tbuehlmann: 30 if @member.disabled == 1
[13:44:40] tbuehlmann: it seems @member is an array and not whatever you think it is
[13:44:41] Arkentias: Looks like @member is an array, maybe you meant it to be a instance of User?
[13:45:04] Arkentias: Have a look at how you declare @member
[13:46:02] alexterziev: tbuehlmann: Arkentias Here is the line where I declare member `27 @member = Member.from_auth(auth_hash)`
[13:46:43] tbuehlmann: it seems that method returns an array now. I suggest debugging at that point or from a rails console
[13:47:38] Arkentias: Yeah look at the definition of "from_auth" in Member and fiddle around in "rails c" as tbuehlmann says
[13:50:08] alexterziev: Arkentias: tbuehlmann I did that already. The from_auth function looks like this in Member model: https://pastebin.com/N10zH68L
[13:50:58] tbuehlmann: I get to go now, but it seems you're in good hands with Arkentias. good luck with this
[13:51:06] alexterziev: Also forgot to mention that the same code is working on Rails 4.2. The error occured after updating to Rails 5.2.
[13:51:16] Arkentias: OK then keep on digging, look at locate_auth and locate_email, put some logs here and there, ..
[13:51:47] Arkentias: locate_auth, locate_email and create_from_auth one by one to make sure they all return a Member object
[13:51:56] Arkentias: *try locate_auth, ..
[13:52:24] Arkentias: (create_from_auth seems good but what about the other ones?)
[13:52:35] Arkentias: Also make sure @member is not declared in multiple spots
[13:53:02] alexterziev: the error is thrown from create_from_auth function
[13:53:17] alexterziev: this line : `member = create(email: auth_hash['info']['email'], nickname: auth_hash['info']['nickname'], activated: false)`
[13:54:07] alexterziev: if I try to save new member using rails console, I get the same error message: wrong number of arguments (given 1, expected 0)
[13:55:04] rikkipitt: has joined #RubyOnRails
[13:56:33] Arkentias: You're calling "Member.from_auth" but the "from_auth" method call you sent me declares it as an instance variable, that's pretty weird
[13:58:03] drale2k_: has joined #RubyOnRails
[13:58:16] alexterziev: Arkentias: here is the member.rb file: http://paste.ubuntu.com/p/VWJyD755Kr/
[13:58:17] Arkentias: I think you meant to declare "def self.from_auth" for example
[14:04:19] Arkentias: I can't really find anything compelling honestly. It does feel like one of the methods or attribute is a reserved name or something
[14:04:46] drale2k_: has joined #RubyOnRails
[14:05:06] alexterziev: Arkentias: I have the same concern about using a reserved name
[14:05:16] alexterziev: any idea how to debug this
[14:05:52] Arkentias: What I would do is put some logging in every method of the stack to make sure the right one is called..
[14:06:00] Arkentias: Dirty but would probably do the job
[14:06:13] status402: has joined #RubyOnRails
[14:06:20] Arkentias: There are probably smarter ways to do it though
[14:08:09] alexterziev: Arkentias: ok I will try that, thanks
[14:08:48] Arkentias: Good luck! Sorry I can't help more
[14:13:53] drale2k_: has joined #RubyOnRails
[14:15:49] jenrzzz: has joined #RubyOnRails
[14:22:39] uplime: has joined #RubyOnRails
[14:28:28] drale2k_: has joined #RubyOnRails
[14:39:34] chouhoulis: has joined #RubyOnRails
[14:39:57] sirensari2: has joined #RubyOnRails
[14:45:59] GodFather: has joined #RubyOnRails
[14:47:02] Linuus: has joined #RubyOnRails
[14:50:26] duderonomy: has joined #RubyOnRails
[14:52:22] jenrzzz: has joined #RubyOnRails
[15:12:24] uplime: has joined #RubyOnRails
[15:13:50] conta: has joined #RubyOnRails
[15:19:31] drale2k_: has joined #RubyOnRails
[15:19:37] conta: has joined #RubyOnRails
[15:27:00] jenrzzz: has joined #RubyOnRails
[15:38:14] drale2k_: has joined #RubyOnRails
[15:44:10] jenrzzz: has joined #RubyOnRails
[15:58:47] beholders_eye: has joined #RubyOnRails
[16:01:04] d0liver: has joined #RubyOnRails
[16:01:33] jenrzzz: has joined #RubyOnRails
[16:08:11] nchambers: has joined #RubyOnRails
[16:17:57] uks: has joined #RubyOnRails
[16:19:59] ciree: has joined #RubyOnRails
[16:21:13] ciree: any opinions on on cities gem vs city-state gem?
[16:26:20] crankharder: has joined #RubyOnRails
[16:32:06] za1b1tsu: has joined #RubyOnRails
[16:36:51] orbyt_: has joined #RubyOnRails
[16:37:31] drale2k_: has joined #RubyOnRails
[16:38:03] jenrzzz: has joined #RubyOnRails
[16:38:23] za1b1tsu: So I am trying to make an Omniauth Strategy, nothing complicated, ultra simple, but I don't really understand what is the problem here: https://gist.github.com/bbtdev/ba3fca2b26bc3f0bb6b31bf1f93bd214
[16:38:36] za1b1tsu: How do I "deal" with the args?
[16:42:32] chouhoulis: has joined #RubyOnRails
[16:50:29] tdy: has joined #RubyOnRails
[16:51:45] Dbugger: has joined #RubyOnRails
[16:51:48] Linuus: has joined #RubyOnRails
[16:52:09] uks: has joined #RubyOnRails
[16:58:23] pLaTo0n: has joined #RubyOnRails
[17:11:54] benlieb: has joined #RubyOnRails
[17:13:00] jenrzzz: has joined #RubyOnRails
[17:14:02] uksio: has joined #RubyOnRails
[17:18:31] orbyt_: has joined #RubyOnRails
[17:21:25] jenrzzz: has joined #RubyOnRails
[17:25:19] conta2: has joined #RubyOnRails
[17:29:44] jenrzzz: has joined #RubyOnRails
[17:47:31] Linuus: has joined #RubyOnRails
[17:48:52] jenrzzz: has joined #RubyOnRails
[17:54:51] jenrzzz: has joined #RubyOnRails
[17:56:53] chouhoulis: has joined #RubyOnRails
[18:03:07] gambl0re: has joined #RubyOnRails
[18:11:42] tdy: has joined #RubyOnRails
[18:14:12] eddof13: has joined #RubyOnRails
[18:15:04] jenrzzz: has joined #RubyOnRails
[18:15:21] benlieb: I’m trying to add an order to an association: has_many :answers, -> {order :question_id}, as: :entity
[18:15:43] benlieb: when I add the -> {order :question_id} I get the error:
[18:16:01] benlieb: uninitialized constant Answer::Entity
[18:16:28] benlieb: the association works fine for posting nested attributes without the order..
[18:17:22] benlieb: maybe I’m not getting the position right of where to put the {order …} ?
[18:28:22] jenrzzz: has joined #RubyOnRails
[18:50:10] catbusters: has joined #RubyOnRails
[18:52:55] jenrzzz: has joined #RubyOnRails
[19:04:14] chouhoulis: has joined #RubyOnRails
[19:08:45] jenrzzz: has joined #RubyOnRails
[19:13:15] chouhoulis: has joined #RubyOnRails
[19:17:59] jenrzzz: has joined #RubyOnRails
[19:18:35] eddof13: has joined #RubyOnRails
[19:23:43] salasrod: has joined #RubyOnRails
[19:30:48] jenrzzz: has joined #RubyOnRails
[19:35:43] jenrzzz: has joined #RubyOnRails
[19:36:59] conta: has joined #RubyOnRails
[19:43:32] jenrzzz: has joined #RubyOnRails
[19:45:19] ziyadb: has joined #RubyOnRails
[19:50:39] Jervis_: has joined #RubyOnRails
[19:59:48] conta: has joined #RubyOnRails
[20:04:03] benlieb: Maybe I’m officially old. I remember when this channel was the most active on IRC around 8 years ago
[20:04:22] jenrzzz: has joined #RubyOnRails
[20:04:52] Linuus: has joined #RubyOnRails
[20:05:29] benlieb: Or it felt that way. Of course in those days there also seemed to be an inordinate number of arrogant jerks sharing their opinions.
[20:06:02] benlieb: Never thought I’d miss them, but the silence is actually scarier
[20:06:18] cnk: has joined #RubyOnRails
[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:15:51] eddof13: has joined #RubyOnRails
[20:16:30] benlieb: tbuehlmann: I found a workaround for the issue I posted above. My most recent comments were just existential angst :)
[20:16:56] tbuehlmann: there's also the more active rails slack
[20:25:10] dviola: has joined #RubyOnRails
[20:25:57] benlieb: ah, good call, I’ll give it a try
[20:50:29] ur5us: has joined #RubyOnRails
[20:52:15] orbyt_: has joined #RubyOnRails
[21:29:52] mikecmpbll: has joined #RubyOnRails
[21:37:04] orbyt_: has joined #RubyOnRails
[21:38:00] jenrzzz: has joined #RubyOnRails
[22:14:41] chouhoulis: has joined #RubyOnRails
[22:22:55] orbyt_: has joined #RubyOnRails
[22:32:02] jenrzzz: has joined #RubyOnRails
[22:36:22] reber: has joined #RubyOnRails
[22:40:32] orbyt_: has joined #RubyOnRails
[22:56:32] Linuus: has joined #RubyOnRails
[23:13:05] orbyt_: has joined #RubyOnRails
[23:13:07] baweaver: We're still around, just busy.
[23:27:23] eddof13: has joined #RubyOnRails
[23:29:42] eddof13: has joined #RubyOnRails
[23:33:06] jenrzzz: has joined #RubyOnRails
[23:48:29] orbyt_: has joined #RubyOnRails