#RubyOnRails - 06 May 2017
« Back 1 day Forward 1 day »
[02:15:54] romeoh_: i'm trying to pass my title_tag translation my query params, but I'd like to remove `reverse_` from the :order and am having a difficult time. http://rubyfiddle.com/riddles/1cad6
[04:18:02] wkoszek: from reading the rails framework code and some docs, my understanding is that `add_foreign_key` is same as t.references.. Am I get it right?
[04:19:04] wkoszek: I'm attempting to do: t.references :posts, foreign_key: true, on_delete: :cascade but the cascading doesn't seem to work (not getting this constraint executed in the SQL)
[07:16:08] gr33nw00d: Hi guys. I'm creating what in PHP I would have called a "library", this is some related functionality. For example, a custom notifier class than handles sending out emails, text messages, etc. Is the best practice to put this code in app/models, lib, or somewhere else?
[07:25:28] pwnd_nsfw: A gem could be a portable version (in other words, easily copied to another application) of something you'd throw in the lib folder.
[07:26:47] apeiros: gr33nw00d: we call them library too. and you usually make a gem out of that library (allows for easier sharing of the library across projects)
[07:27:22] apeiros: gr33nw00d: rails has a specialized kind of library, called "engine", which hooks into some of rails' parts
[07:28:15] gr33nw00d: Hmmm. Thanks very much for the responses. I'm now thinking that this libraries are too application-specific to consider sharing them outside of this project, however they don't deal with any DB stuff.
[07:28:31] apeiros: gr33nw00d: http://guides.rubygems.org and http://guides.rubyonrails.org/engines.html
[07:29:30] gr33nw00d: if I add a class to lib/xx.rb, will rails auto load it and it will be available globally?
[07:31:45] gr33nw00d: Have you guys seen strange errors like this: "A copy of XXX has been removed from the module tree but is still active!"? I think it's due to me using models/libraries in a novice way.
[07:35:07] apeiros: i.e. x = Some::Module; <reloading happens here, replacing Some::Module with a different object>; x.foo # still uses the old Some::Module
[07:48:48] pwnd_nsfw: See, PHP wouldn't be so bad if the people who programmed with/for it weren't brain damaged
[07:49:51] pwnd_nsfw: I was writing my own MVC framework in PHP before I even knew what mvc was. It just felt better to have things separated.
[07:51:01] gr33nw00d: Here is an example that triggers the "removed from the module tree" error: https://gist.github.com/otang/4a97c8303205763b9b1732ef6f743f08
[07:52:10] pwnd_nsfw: And if that code runs something.... remove executing code from initializer please
[07:53:09] gr33nw00d: Without the actionmailer I get the expected error: "NameError: uninitialized constant"
[07:53:38] apeiros: php is a bad language, but programs aren't bad because of the language being bad.
[07:53:41] pwnd_nsfw: gr33nw00d, I think you're probably doing something incredibly wrong with your code
[07:56:40] gr33nw00d: Here is my team model: https://gist.github.com/otang/c0d7d37c498c5867181d9fedb5e75eee (the notify_admin_of_registration lifecycle callback is what triggers the error).
[07:59:30] gr33nw00d: This gist is updated: https://gist.github.com/otang/c0d7d37c498c5867181d9fedb5e75eee
[08:00:15] gr33nw00d: I think I'm doing something wrong with my SlackNotifier class, as it seems to be the constant that causes the error after disabling pieces of code. It still causes the error if I move it to /lib
[08:03:38] gr33nw00d: So that's the error that I expect - "uninitialized constant", however "A copy of Team has been removed from the module tree but is still active!" is unexpected.
[08:04:48] tamouse__: so grasping, but i think that means somewhere in that mess you've redefined the Team constant
[08:07:12] tamouse__: let's see what that looks like. note you can create new files in gist by clicking on the Add File button to the left of the "Update" button
[08:12:27] gr33nw00d: My ignorant theory, is that deliver_later is keeping a reference to the Team model, passed to it via self keyword, and then some sort of rails reload magic is happening before the deliver_later queue is processed?
[08:19:46] gr33nw00d: However something weird is that SlackNotifier is in app/models/services/slack_notifier.rb
[08:23:51] gr33nw00d: Is spring what prevents you from having to restart your server after making changes?
[08:23:54] pwnd_nsfw: They're great tools.... until something totally trivial happens, and it explodes
[08:26:18] tamouse__: gr33nw00d: keep the idea of passing the id and retrieving the record in the mailer, though
[08:26:50] tamouse__: it's generally a better practice for dealing with any background jobs or things which will run between stacks
[08:29:17] tamouse__: also, there are better ways of dealing with how mail is handled in non-prod environments than just turning it completely off
[08:46:33] nachoman: Hi all, anyone willing to discuss about sprockets issues?, I have a nice one here with ember gem :)
[11:18:55] JDeen: Hello... I got a question on writing rspec requst spec. I got a controller acition that redirects back. When I try to test it, I get an error that HTTP_REFERER has not been set. How can I set it in a request spec?
[11:26:31] shinzah: I'm trying to create some specs for OAuth2 flows. I'm using the oauth2 library to do so. But I'm having some trouble with this. Anyone who has some experience with mocking oauth applications?
[15:26:24] tildes: I am running `rake test:benchmark` for my toy app, Ruby 2.2.3/MRI. The output says metrics for memory and objects are not supported. Rails Performance Testing Guide mentions that MRI can be GC-patched. However, the freshest patch I can find is for 1.9.3. Does this mean, that if I want memory and object metrics in Ruby 2.2.3 I would be better of with something other than MRI, JRuby for instance?
[15:37:36] mordof: i set up a new rails 5 app, and didn't think about setting it to use haml first. currently running in development - how do i get it to use my haml files for views? i imagine i'm missing a step about the asset pipeline, but not sure what
[15:37:57] tildes: Also my performance test for GET '/' gives "Completed 200 OK in 23ms", where as if I actually use a browser, the request logging says "Completed 200 OK in 1420ms". :-D
[15:42:40] tbuehlmann: mordof: have you added haml-rails to your Gemfile, bundle installed and restarted the rails server?
[16:31:12] shinzah: I have created a client side app with OAuth2 library. But when I visit the authorize_url it sort of 'leaves my test env' because I cannot use the Factory's which I have created anymore. Any advice?
[19:49:22] Exuma: Does anyone use --webpack to manage css on Rails 5.1? I'm trying to very simply use a background-image: url() and I dont know how to link to an image...
[20:00:07] shilon: Hello everyone, I have a covers table and a posts table, inside the posts table I have a field_for :cover and for no reason, I always get cover: nil but all other attributes are ok…
[20:36:26] nickjj: Exuma, i wrote a webpack plugin a few years ago that tags images (or anything) with md5 hashes and is backwards compatible with all of the rails template helpers