« Back to channel list

#RubyOnRails - 07 November 2017

« Back 1 day Forward 1 day »
[00:01:38] twilling: has joined #RubyOnRails
[00:02:22] twilling: I have the following in my controller and `find_by!` isn’t raising an exception for me. This is weird, right? `Article.published.find_by!(slug: params[:slug])`
[00:02:50] twilling: (This is in a Rails 5.1.2 app)
[00:04:31] baweaver: http://api.rubyonrails.org/classes/ActiveRecord/FinderMethods.html#method-i-find_by-21
[00:04:39] baweaver: Looks to be.
[00:04:57] baweaver: What's the rest of the code around it look like? Getting any other errors?
[00:08:35] dminuoso: twilling: Also be sure to check your controller, included modules and engines whether the have some rescue_from if you don't get an exception.
[00:08:58] twilling: I get errors in the view because I’m calling methods on nil, but the entire contents of this `show` method is `@article = Article.published.find_by!(slug: params[:slug])` it’s weird
[00:08:58] dminuoso: (You can trivially also just test by doing a begin/rescue block and just log the exception
[00:09:09] havenwood: rescue ActiveRecord::RecordNotFound
[00:09:25] dminuoso: twilling: gist the model Article
[00:11:57] havenwood: twilling: If there's nothing suspicious in Article, check application_record.rb as well.
[00:14:57] baweaver: what if published is empty?
[00:16:59] dminuoso: ACTION pokes baweaver
[00:17:09] dminuoso: baweaver: that was the wrong link by the way
[00:17:24] dminuoso: What is this weirdness?
[00:18:58] jphase: has joined #RubyOnRails
[00:23:18] conta: has joined #RubyOnRails
[00:25:12] cagomez: has joined #RubyOnRails
[00:30:46] xaviergmail: has joined #RubyOnRails
[01:04:14] sevenseacat: has joined #RubyOnRails
[01:05:20] orbyt_: has joined #RubyOnRails
[01:20:18] weaksauce: has joined #RubyOnRails
[01:26:09] cagomez: has joined #RubyOnRails
[01:31:45] bdnelson: has joined #RubyOnRails
[02:09:12] bdnelson: has joined #RubyOnRails
[02:15:20] Cork: has joined #RubyOnRails
[02:26:30] rfoust: has joined #RubyOnRails
[02:33:10] Cork: has joined #RubyOnRails
[02:33:20] justrying: has joined #RubyOnRails
[02:44:23] guacamole: has joined #RubyOnRails
[02:46:18] orbyt_: has joined #RubyOnRails
[03:10:13] irishfromua: has joined #RubyOnRails
[03:12:46] xpl0iter: has joined #RubyOnRails
[03:30:52] chouhoulis: has joined #RubyOnRails
[03:31:06] Cork: has joined #RubyOnRails
[03:37:22] fragamus: has joined #RubyOnRails
[03:40:13] Iacobus: has joined #RubyOnRails
[03:41:26] mtkd: has joined #RubyOnRails
[03:47:24] agent_white: has joined #RubyOnRails
[03:47:35] MrCrackPotBuilde: has joined #RubyOnRails
[03:50:24] MrCrackPotBuilde: if i want to create a splash screen/ entry page can i use css or scss to remove the header and footer so its just the welcome page displayed untill you goto the homepage
[03:51:04] MrCrackPotBuilde: or could i create a <%if%> <%else%> on the application.html.erb
[03:51:48] MrCrackPotBuilde: so if route is welcome then dont display header or footer else display header footer
[03:55:23] agent_white: has joined #RubyOnRails
[03:57:30] agent_white: has joined #RubyOnRails
[04:06:02] Saukk: has joined #RubyOnRails
[04:06:17] quazimodo: has joined #RubyOnRails
[04:13:54] krz: has joined #RubyOnRails
[04:16:57] fschuindt: has joined #RubyOnRails
[04:19:23] andrew9184: has joined #RubyOnRails
[04:22:00] jphase: has joined #RubyOnRails
[04:50:05] veloutin: has joined #RubyOnRails
[04:59:36] fschuindt: has joined #RubyOnRails
[05:01:34] jphase_: has joined #RubyOnRails
[05:22:00] sagax: has joined #RubyOnRails
[05:24:31] dminuoso: MrCrackPotBuilde: The classical way would be to use two different layouts, and use different layouts in your controller (you could use two separate base controllers for this)
[05:28:57] MrCrackPotBuilde: do you know of any reference guides i could refer to ??
[05:29:34] dminuoso: http://guides.rubyonrails.org/layouts_and_rendering.html
[05:30:11] dminuoso: Layout Inheritance in particular
[05:42:29] fschuindt: has joined #RubyOnRails
[05:47:12] Puffball: has joined #RubyOnRails
[05:47:50] waveprop: has joined #RubyOnRails
[05:48:32] waveprop: is it normal call methods from a rack middleware from config.ru?
[05:48:40] waveprop: * normal to
[05:52:50] dminuoso: waveprop: Can you be more specific?
[05:57:37] waveprop: dminuoso: yeah. first of all, this is a rack question not rails
[05:59:17] MrCrackPotBuilde: has joined #RubyOnRails
[05:59:39] waveprop: i'm trying to figure out how to pass parameters from one rack middleware into the next in the stack. i'm supposed to do this by adding values to the env, correct? i.e., if i have two middlewares called Validator and Router, i can have Validator set env[validator] = {...} and then have Router access those values?
[06:09:04] dminuoso: waveprop: Yeah. Be sure to look at Rack::Request (which is basically a handy container for that env hash)
[06:15:55] waveprop: dminuoso: right on. thank you sir
[06:16:33] fschuindt: has joined #RubyOnRails
[06:27:30] srinidhi: has joined #RubyOnRails
[06:29:39] duderonomy: has joined #RubyOnRails
[06:31:08] MrCrackPotBuilde: has joined #RubyOnRails
[06:37:11] dionysus69: has joined #RubyOnRails
[06:37:44] kapil___: has joined #RubyOnRails
[06:45:33] dionysus69: has joined #RubyOnRails
[06:49:09] waveprop: I'm sorry. and is the initialize(app) parameter the upstream or downstream middleware? does app mean the next middleware in the stack or the previous
[06:50:10] waveprop: app is the input to the current middleware, right?
[06:50:55] apeiros: has joined #RubyOnRails
[06:52:41] gr33nw00d: has joined #RubyOnRails
[06:53:18] gr33nw00d: Are there any gems that help with parameter parsing, ie. say I want my API to include filters like GET /sales?start_date=$gt:2017-01-01
[06:53:29] dionysus69: I am getting lots of Started GET "/admindb/scripts/setup.php" errors in production log. as I understand I can block these with fail2ban, but can anyone experienced send me a jail file as a template? never used fail2ban and don't know what the optimal settings are
[06:54:47] dionysus69: also, is there any vulnerability I should be aware of in rails framework? perhaps similar to this vulerability, can attacker execute random rb file just like this?
[06:56:35] kies: has joined #RubyOnRails
[06:58:38] dminuoso: waveprop: I suggest you create a simple rack application manually. It's best to gain intuition yourself.
[06:59:04] dminuoso: dionysus69: Rails has vulnerabilities, yes.
[06:59:34] dionysus69: and where can I look them up?
[06:59:44] dionysus69: conventional ways to counter them ? :D
[07:00:07] dminuoso: dionysus69: Ask yorickpeterse when he's around, I know they use some decent took in their pipeline that automatically checks gem versions.
[07:01:12] dionysus69: checking gem versions for what ? just curious?
[07:01:16] dminuoso: dionysus69: Also http://guides.rubyonrails.org/security.html is a crucial read, it outlines some of the more common attack vectors and how to prevent them.
[07:01:29] dminuoso: dionysus69: Against gems with known CVEs
[07:01:58] dionysus69: oh I see, always helpful dminuoso xD thanks
[07:02:25] dminuoso: dionysus69: Be also sure to look into security articles on your web server (especially if you run some external server like nginx or apache)
[07:02:41] dionysus69: ye I use nginx as proxy
[07:02:48] dminuoso: Does nginx also serve static assets?
[07:02:49] dionysus69: which redirects to stock puma
[07:03:29] dionysus69: hmm not sure, I guess? assets are in public dir so the request directly fetches them, not going through rails app I suppose
[07:03:33] dionysus69: if that's what you are asking
[07:07:02] dionysus69: I just checked some stackoverflow articles and I think it needs a specific nginx conf block to make it serve static files, so I guess mine is not serving
[07:12:15] waveprop: will do, dminuoso
[07:12:56] waveprop: anyway railscast 151 answered some questions about how to get the middleware to act a as a filter which is what i've been struggling to understand
[07:14:28] waveprop: specifically how to pass args into the class-level middleware from config.ru
[07:30:01] conta: has joined #RubyOnRails
[07:31:44] apeiros: has joined #RubyOnRails
[07:37:26] arBmind: has joined #RubyOnRails
[07:38:18] snickers: has joined #RubyOnRails
[07:39:17] apeiros: has joined #RubyOnRails
[07:43:24] drale2k_: has joined #RubyOnRails
[07:46:28] alexday: so yestarday for the accepts_nested_attributes_for, I had to write a custom validation that would do the validation in the application model rather than tags model. because there were a couple of problems. the uniqueness validations wasn't triggering while creating new_record and while updating if I deleted a key and then added the same key with different name then the update would fail with duplicate
[07:46:30] alexday: key error.
[07:48:34] alexday: https://gist.github.com/argentum47/43e994f133a3fc47175008ad01a0e0fe#file-application-rb-L7
[07:57:35] gambl0re: has joined #RubyOnRails
[07:58:15] MrCrackPotBuilde: has joined #RubyOnRails
[07:58:29] defsdoor: has joined #RubyOnRails
[07:59:02] MrCrackPotBuilde: has joined #RubyOnRails
[08:05:26] pfg: has joined #RubyOnRails
[08:26:55] mikecmpbll: has joined #RubyOnRails
[08:33:33] drale2k_: I am struggling with this for days.. please someone take a look :/ https://stackoverflow.com/questions/46906968/wrong-path-for-nested-controller-in-rails
[08:36:11] jphase: has joined #RubyOnRails
[08:39:21] DrYockel: has joined #RubyOnRails
[08:41:59] Dimik: has joined #RubyOnRails
[08:46:16] iamarun: has joined #RubyOnRails
[08:49:58] jphase: has joined #RubyOnRails
[08:59:06] jphase: has joined #RubyOnRails
[09:00:42] sevenseacat: your form_with is missing the :job namespace
[09:00:43] arBmind: has joined #RubyOnRails
[09:00:46] blackmesa1: has joined #RubyOnRails
[09:01:03] sevenseacat: form_with model: [@operation, @agent, :jobs, @job]
[09:01:30] sevenseacat: your resources :meterpreter should also be plural, meterpreters
[09:01:47] sevenseacat: controllers are also always plural
[09:02:08] sevenseacat: I'll write an answer
[09:12:25] mikecmpbll: has joined #RubyOnRails
[09:19:44] waveprop: http://termbin.com/p9lh => i'm not sure why i'm getting this NoMethodError with my simple rack middleware stack. But i suspect it's due to how i'm trying to do things at class-level? any guidance would be greatly appreciated.
[09:19:51] drale2k_: sevenseacat: thanks, will try in 2 min
[09:20:12] drale2k_: should controller be plural even though it's wrong wording? "Meterpreters" is wrong for example
[09:20:46] drale2k_: what it really should be is multiple Meterpreter JobS
[09:21:01] sevenseacat: you named it that way, you tell me
[09:21:10] sevenseacat: controllers are always plural though
[09:21:33] drale2k_: ok then i will rename it to MeterpreterJobs
[09:23:46] ur5us: has joined #RubyOnRails
[09:24:06] ur5us: has joined #RubyOnRails
[09:27:47] drale2k_: sevenseacat: hm not sure what's going but but i changed now Meterpreter to MeterpreterJobs for both, Controller and Model and now the view renders wirhout touching form_with
[09:28:11] sevenseacat: something sure is going on.
[09:29:26] tbuehlmann: btw, why is it ApplicationController instead of ApplicationsController?
[09:30:26] sevenseacat: because you only have one application? not sure tbh. maybe because you never route there so it can be different
[09:31:29] simmerz: has joined #RubyOnRails
[09:31:43] drale2k_: is the namespace i need for the model based on the folder structure? Like "class Jobs::MeterpreterJob" is in models/jobs/
[09:32:18] sevenseacat: no. you added that namespace yourself.
[09:32:32] drale2k_: ah ok so it's because of the routes.rb
[09:32:53] tbuehlmann: when using `resource :singular_thingy` I also have a SingularThingiesController (plural), even if there's only one
[09:33:10] tbuehlmann: I guess it's just historic
[09:33:56] matthewd: Yeah, it's resources that have plural controllers by definition; non-resource controllers can be whatever you like
[09:37:14] sevenseacat: nearly all of your routes should be resource routes anyway
[09:45:16] marr: has joined #RubyOnRails
[09:47:02] redhedded1: has joined #RubyOnRails
[10:07:53] Grafikart: has joined #RubyOnRails
[10:08:10] iamarun: has joined #RubyOnRails
[10:08:39] Grafikart: Hi, I have a pretty specific question, and I couldn't find a solution diggin into the code. Is there a way, in a custom generator, to detect if the generator is reversed or not ?
[10:09:13] Grafikart: I would like to use the ask method from Thor but it "ask" even when calling "rails d ..."
[10:12:48] Grafikart: I should have used byebug sooner... @behaviour gives me :invoke or :revoke ;)
[10:21:03] drale2k_: has joined #RubyOnRails
[10:28:23] kapil___: has joined #RubyOnRails
[10:29:20] zamuro: has joined #RubyOnRails
[10:30:53] jphase: has joined #RubyOnRails
[10:40:01] jphase: has joined #RubyOnRails
[10:41:01] ferr: has joined #RubyOnRails
[10:44:54] sekmo: has joined #RubyOnRails
[10:50:50] ferr: has left #RubyOnRails: ("WeeChat 1.9.1")
[10:55:20] jottr__: has joined #RubyOnRails
[10:55:33] drale2k_: has joined #RubyOnRails
[10:58:23] jphase: has joined #RubyOnRails
[11:04:51] drptbl: has joined #RubyOnRails
[11:14:28] MrCrackPotBuilde: any idea how to stop a new tab or window being opened if a link is clicked that directs to another controller
[11:15:47] ArTiSTiX: has joined #RubyOnRails
[11:16:46] tbuehlmann: MrCrackPotBuilde: how do you generate the link?
[11:17:45] mikecmpbll: use left mouse button not middle :D
[11:18:13] MrCrackPotBuilde: <li><%= link_to "Home", 'main/index' %></li>
[11:18:42] tbuehlmann: that link shouldn't open in a new tab or window
[11:18:43] MrCrackPotBuilde: im left clicking
[11:18:53] tbuehlmann: do you have some javascript in place that changes links?
[11:19:11] Ergo: has joined #RubyOnRails
[11:19:12] MrCrackPotBuilde: nope the other links are just <%= link_to "About", '#' %>
[11:19:26] quazimodo: has joined #RubyOnRails
[11:19:37] MrCrackPotBuilde: that also opens a new window although not sure why
[11:19:43] MrCrackPotBuilde: it should be the same page
[11:21:59] MrCrackPotBuilde: ah i figured it out for some reason it wasnt loading in my default browser sorry false alarm
[11:28:38] drale2k_: has joined #RubyOnRails
[11:42:15] alexday: I had a quesyion. I have applications has_many configuration. now in after_save of Application, there a loop that calls a Configuration class 2 ice. in the class method there is something like Configuration.new(....values..). and then configuration.save. and when I do a FactoryGirl.create(:configuration), then in the end it errors out sayng Application has already been taken
[11:42:51] alexday: I am not sure how is this happening
[11:42:55] alexday: any ideas?
[11:44:47] sevenseacat: you'll need to show your code.
[11:46:21] blackbaba: has joined #RubyOnRails
[11:52:21] user121212: has joined #RubyOnRails
[11:56:43] user121212: Hey, any readymade solution for feature switches? thinking about rollout +active admin
[11:58:28] quazimodo: has joined #RubyOnRails
[12:03:34] fschuindt: has joined #RubyOnRails
[12:05:07] blackbaba: has joined #RubyOnRails
[12:07:55] alexday: sevenseacat https://gist.github.com/argentum47/88c41b8b332e5892943aef3a91abae2d
[12:08:07] alexday: tell me if anyone needs to see anything more
[12:08:15] alexday: my rails foo is so down.
[12:10:44] sevenseacat: can you add your application model?
[12:17:04] alfiemax: has joined #RubyOnRails
[12:17:16] alexday: I can;t seem to do FactoryGirl.create(:configuration)
[12:19:13] sevenseacat: your callbacks in Application, I'd try debugging and writing tests around those.
[12:20:42] sevenseacat: actually, I think I know what's causing it
[12:22:01] sevenseacat: FG builds configuration, which builds and saves an application, and then the callbacks create and save a configuration
[12:22:19] sevenseacat: so when FG tries to save the configuration it created, it cant
[12:23:07] alexday: yeah. that actually makes sense. when I remove the .save the creation succeeds
[12:23:59] ij: has left #RubyOnRails: ("WeeChat 1.9.1")
[12:24:33] sevenseacat: reason #40001 why callbacks can bite you
[12:26:57] AntiSpamMeta: has joined #RubyOnRails
[12:30:08] jphase: has joined #RubyOnRails
[12:32:41] quazimodo: has joined #RubyOnRails
[12:39:18] jphase: has joined #RubyOnRails
[12:48:30] jphase: has joined #RubyOnRails
[12:57:38] jphase: has joined #RubyOnRails
[13:02:17] truenito: has joined #RubyOnRails
[13:07:04] jphase_: has joined #RubyOnRails
[13:07:55] blackbaba: has joined #RubyOnRails
[13:08:08] truenito: has joined #RubyOnRails
[13:21:54] GodFather_: has joined #RubyOnRails
[13:25:12] nzst: has joined #RubyOnRails
[13:26:12] nzst: Hi, when I optimize for performance I use rack-mini-profiler and bullet. Does anyone have other gems or methodologies outside of those gems for optimizing my application that they've found useful?
[13:27:11] jphase: has joined #RubyOnRails
[13:30:38] dminuoso: nzst: rack-mini-profile + memory_profiler + stackprof usually is enough
[13:31:43] nzst: dminuoso: thank you, I will try out the couple I haven't used before
[13:32:16] dminuoso: nzst: flamegraphs will be useful by the wa
[13:32:22] dminuoso: (But you dont have to use that)
[13:32:48] keegnotrub: has joined #RubyOnRails
[13:32:53] dminuoso: But stackprof is probably my favourite tool for profiling ruby. :)
[13:47:09] jphase: has joined #RubyOnRails
[13:48:28] jphase_: has joined #RubyOnRails
[13:50:13] mauro1254: has joined #RubyOnRails
[13:50:29] jphase_: has joined #RubyOnRails
[13:52:55] mauro1254: Hi folks, is it possible to associate objetcs in a has_many association without saving it to the DB but delegating it to the parent record?
[13:57:50] arBmind: has joined #RubyOnRails
[13:58:57] bob14: has joined #RubyOnRails
[14:03:27] mikecmpb_: has joined #RubyOnRails
[14:06:45] alfie: ACTION eyes the bot
[14:07:03] alfie: mauro1254: in order for data to persist, you need to save it somewhere. that's what the database is for. what is the problem you're trying to solve?
[14:07:17] drale2k_: has joined #RubyOnRails
[14:07:28] helpa: It seems like you are asking for a specific solution to a problem, instead of asking about your problem. This often leads to bad solutions and increases frustration for you and those trying to help you. More: http://meta.stackexchange.com/a/66378
[14:07:34] dminuoso: alfie: You're just not whitelisted.
[14:07:38] alfie: ah, that'd be why
[14:08:29] GodFather: has joined #RubyOnRails
[14:08:44] mauro1254: alfie : I have a record with a few associated records, i would like to set new associated records (add new, remove o updated already associated) and reflect changes to the database when I save parent object
[14:09:39] alfie: mauro1254: alright. and, what's the problem this solves?
[14:09:59] alfie: (i'll keep iterating up the yak stack until we find something that looks like a problem in itself and not solutions to other problems :P)
[14:11:49] mauro1254: Associated objects are saved even if the parent object is not valid
[14:15:26] alfie: mauro1254: which version of rails are you using?
[14:16:08] alfie: have a look into validates_associated
[14:19:13] rfoust: has joined #RubyOnRails
[14:19:45] alfie: (brb, eating lunch)
[14:22:41] nzst: Is there a way to eager load when the association is on the same table?
[14:24:08] fschuindt: has joined #RubyOnRails
[14:29:02] ahrs: has joined #RubyOnRails
[14:30:37] fragamus: has joined #RubyOnRails
[14:39:21] TinkerTyper: has joined #RubyOnRails
[14:42:14] mtkd: has joined #RubyOnRails
[14:53:04] AzaToth: has joined #RubyOnRails
[14:58:42] tcopeland: has joined #RubyOnRails
[15:00:26] twilling: has joined #RubyOnRails
[15:03:33] hgost: has joined #RubyOnRails
[15:09:59] mauro1254: has joined #RubyOnRails
[15:14:08] iamarun: has joined #RubyOnRails
[15:17:35] iamarun: hello all ,
[15:18:23] iamarun: is there any tutorial or resource so i can learn about the different server types and
[15:18:40] iamarun: how they differ and what should i choose and for what purpose
[15:18:58] iamarun: like i came to know puma is default server
[15:19:12] tvw: has joined #RubyOnRails
[15:19:16] iamarun: and there are things like unicorn and ....
[15:19:31] iamarun: and advice i am starting out on to ruby
[15:19:40] iamarun: and ruby on rails
[15:20:08] iamarun: php has lots of pit falls does rails solve them
[15:20:25] iamarun: and is rails better to php on security
[15:20:36] iamarun: sry for comparing rails with a language
[15:21:01] iamarun: may be codeigniter , larvel match to rails
[15:21:03] havenwood: iamarun: Here's a talk that gives a good introduction to how Unicorn works: https://www.youtube.com/watch?v=2rAoasxZKGU
[15:22:53] alfiemax: has joined #RubyOnRails
[15:24:05] iamarun: and also please give me websites , screencast youtube channel where i can learn rails
[15:24:19] iamarun: and thansk @havenwood
[15:24:23] iamarun: i am watching
[15:25:22] tvw: I am trying to create a general collection with AR without limiting, which models can go into the class. Example see here: https://gist.github.com/tvw/378aa052e73e1af8624c664f057ab5f4
[15:25:56] tvw: So how do I do this?
[15:26:33] tvw: sorry: "can go into the collection" (not "class")
[15:29:04] dviola: has joined #RubyOnRails
[15:30:51] twilling: has joined #RubyOnRails
[15:32:23] mikecmpbll: has joined #RubyOnRails
[15:37:00] dinoangelov: has joined #RubyOnRails
[15:39:04] fryguy: iamarun: unless you have good reason not to, use puma.
[15:39:24] Saukk: has joined #RubyOnRails
[15:39:39] nzst: dminuoso: if you're inclined could you help me interpret some stackprof results? https://privatebin.net/?6f246a158b35ff15#B5Lju+nzHGD4rOawlRvWAfkheSpD3WCFHqnvcN2+GTo=
[15:40:41] nzst: I just loaded a page in my rails app
[15:40:44] dminuoso: nzst: Sure. What are you looking at?
[15:41:28] nzst: Just a Rails application, I refreshed a page that has been running pretty slow. Lots of data loads in with database calls and jbuilder view rendering
[15:42:27] dminuoso: nzst: Just for completeions sake, can you also gist the log output for that request?
[15:43:07] dminuoso: nzst: And also a screenshot of the Network tab analysis of the request in your chrome devtools.
[15:43:18] iamarun: fryguy, i want to make my website as secure as possible. At the same time i want server pages for like a 7000 users
[15:44:19] fryguy: iamarun: neither of those statements change mine
[15:44:42] dminuoso: iamarun: puma scales quite well. Also you will still likely have nginx in front (at least for TLS termination), so it really doesnt matter.
[15:44:51] nzst: dminuoso: here is better results after removing rack-mini-profiler https://privatebin.net/?6e7bdebf2bd1a9e8#Txx13k788M+32lsPoEBkRVkiIsUQkl7a/WZMAVLkjCo= . I'll see what else I can share without leaking org IP
[15:45:09] dminuoso: nzst: Feel free to just manually edit and anonymize.
[15:45:25] xco: has joined #RubyOnRails
[15:46:15] dminuoso: nzst: 14128 (376.3%) 34 (0.9%) Jbuilder#_map_collection
[15:46:36] xco: Hi I have a question. Can someone please explain the relationship between Puma and Rack in a Rails app? I get both are web servers from http://puma.io/ and http://rack.github.io/, why do we need two webservers?
[15:46:52] fryguy: xco: rack is not a webserver, it's a protocol for webservers
[15:47:14] xco: so rack is a protocol for puma in a rails app? correct?
[15:47:23] fryguy: xco: or any other ruby framework
[15:47:24] dminuoso: xco: rack is a library to build web servers from.
[15:47:32] dminuoso: xco: puma basically runs your rack application.
[15:47:38] fryguy: rails speaks rack, sinatra speaks rack, etc.
[15:47:49] fryguy: puma understands rack, so it can run those frameworks
[15:47:53] xco: ooooooo
[15:47:58] xco: excellent!!!
[15:48:01] xco: confusion cleared!
[15:48:08] xco: thank you both!
[15:48:24] fryguy: xco: if you are familiar with wsgi from python, wsgi == rack (basically)
[15:48:34] dminuoso: xco: In simple terms, rack just lets you stack middlewares (each of which can look at the request object, and produce some output or pass information to the next middleware). The last middleware is called an "application", and for rails that final middleware ("application") is rails itself.
[15:48:37] xco: hehe, let’s not go there,
[15:48:38] dminuoso: So rails is a rack application
[15:49:01] dminuoso: xco: Type `rails middlewares` to see the entire rack stack for your application.
[15:49:13] dminuoso: xco: Some things like request logging happen in those middlewares. :)
[15:49:24] troys: has joined #RubyOnRails
[15:49:54] xco: dminuoso: thanks! i’m enlightened now
[15:50:20] nzst: dminuoso: woah, that is happening a lot. A bunch of this log is redundant (happens over and over), here is a sample: https://privatebin.net/?b8b908abae591644#n6OtRThsAyKBab/WcNIjw15a7TVt1/P4nQrdrD+l6Ks=
[15:51:06] dminuoso: nzst: Im particularly interested in the timings at the end of each log entry.
[15:51:22] dminuoso: nzst: Can you provide an updated stackprof sample?
[15:51:44] nzst: dminuoso: What do you mean updated?
[15:52:12] nzst: like one with more data?
[15:53:12] nzst: https://privatebin.net/?d34b1b348008069d#Mqggz9FEU+Lo1ApBWbEh+fymYffgE+JzEiD7BdRrQqo=
[15:55:13] nzst: dminuoso: for the network profiler in chrome, it's pointing to 3+ seconds on a json request (this is becoming more apparent on what the issue is as I talk through it)
[15:55:30] xco: ok now one more question, these are the middleware in my app? what is each one of them called? for instance what is the Head in use Rack::Head in https://gist.github.com/xcobar/42a84936b551f6fa36e1073362fbb0f3 ?
[15:56:00] iamarun: guys unicorn seems legit good . So how does it scale to puma
[15:56:34] fryguy: iamarun: worse in every way
[15:57:06] fryguy: iamarun: i'm going to repeat myself one more time: unless you have a good reason not to, use puma.
[15:58:02] iamarun: fryguy, got it fry
[15:58:37] nzst: dminuoso: thanks for the help, please let me know if anything else stands out or if you have any tips for fixing
[15:58:51] xco: dminuoso: fryguy: ok now one more question, these are the middleware in my app? what is each one of them called? for instance what is the Head in use Rack::Head in https://gist.github.com/xcobar/42a84936b551f6fa36e1073362fbb0f3 ?
[15:58:52] dminuoso: nzst: Okay well Im unsure what's going on with the percentage. But that aside, it's seems that the vast majority is somehow spent inside jbuilder.
[15:59:15] dminuoso: xco: Rack::Head is just a middleware that rack comes with
[15:59:26] dminuoso: xco: https://github.com/rack/rack/blob/master/lib/rack/head.rb
[15:59:36] dminuoso: Its very easy to see what it does.
[16:00:14] iamarun: is rvm better to rbenv
[16:00:20] fryguy: iamarun: no
[16:00:24] dminuoso: iamarun: chruby+ruby-install is the generally preferred setup
[16:00:30] dminuoso: Its much simpler, less prone to breal.
[16:00:34] dminuoso: break even.
[16:00:41] fryguy: i still like chruby over rbenv, but you should be using one of those 2 and not rvm nowadays
[16:00:48] fryguy: err, i like rbenv over chruby
[16:01:09] dminuoso: fryguy: Your subconsciousness is trying to tell you something.
[16:01:23] fryguy: dminuoso: :)
[16:01:32] iamarun: i am making a ruby virutal box and having a shared folder to my /Documents . Is it a good idea ?
[16:01:44] fryguy: i've set both up, there's a couple of things I like better about rbenv in our infra, notably stricter enforcement of .ruby-version
[16:01:46] dminuoso: xco: Interesting middlewares that are obvious are `use Rails::Rack::Logger`, `use ActionDispatch::ShowExceptions`, `use ActiveRecord::Migration::CheckPending`
[16:02:18] dminuoso: `use ActionDispatch::Reloader` is also a highly interesting one. if you ever wondered how rails knows to reload code between requests, this is the reason.
[16:02:36] dminuoso: use ActionDispatch::Session::CookieStore this is how sessions into existence
[16:04:20] xco: dminuoso: is there a link documenting all this?
[16:05:10] xco: and also you said this “The last middleware is called an "application", and for rails that final middleware ("application") is rails itself.” where does rails fall in this stack? https://gist.github.com/xcobar/42a84936b551f6fa36e1073362fbb0f3 the last one?
[16:09:13] orbyt_: has joined #RubyOnRails
[16:09:15] iamarun: https://learnrubythehardway.org/ https://www.railstutorial.org/ are they good books for rails ?
[16:10:01] fryguy: iamarun: they are fine
[16:11:18] jnollette: has joined #RubyOnRails
[16:11:43] iamarun: is it possible to create a lampp like setup ( i mean lemp ) for rails ?
[16:12:36] fryguy: iamarun: what do you mean?
[16:13:10] iamarun: i mean a server setup like apache2 or ngnix for php ... iam from a php background
[16:13:26] iamarun: or rails -s the only way
[16:13:38] iamarun: i want to keep a personal rails server for my self
[16:13:44] fryguy: well, when you using nginx for php, how do you run php?
[16:13:45] iamarun: and go from there
[16:13:45] havenwood: iamarun: http://www.mikeperham.com/2015/01/05/cgi-rubys-bare-metal/
[16:14:20] iamarun: i have not tried lempp for php
[16:14:31] iamarun: i heard a co-worker say about ti
[16:14:36] havenwood: iamarun: You can do everything from CGI to mod_rails to straight Webrick or Rack or a Rack adapter like Rails.
[16:19:43] iamarun: which is better ?
[16:21:14] fryguy: iamarun: puma, which is rack
[16:22:16] iamarun: thanks all questions answered
[16:25:35] jarnalyrkar: has joined #RubyOnRails
[16:26:19] mikecmpbll: has joined #RubyOnRails
[16:36:08] Technodrome: has joined #RubyOnRails
[16:36:37] cagomez: has joined #RubyOnRails
[16:40:00] eean: has joined #RubyOnRails
[16:54:43] dionysus69: has joined #RubyOnRails
[16:56:53] Technodrome: has joined #RubyOnRails
[17:03:05] keegnotrub: has joined #RubyOnRails
[17:07:37] keegnotrub: has joined #RubyOnRails
[17:08:24] chouhoulis: has joined #RubyOnRails
[17:11:50] mtkd: has joined #RubyOnRails
[17:12:09] orbyt_: has joined #RubyOnRails
[17:15:06] dionysus69: has joined #RubyOnRails
[17:21:24] conta1: has joined #RubyOnRails
[17:27:41] dionysus69: does anyone experience problem with bitbucket/capistrano deploy? I suddenly have access denied but I have public key included in the bitbucket settings... :S
[17:29:32] Puffball: has joined #RubyOnRails
[17:29:56] Technodrome: has joined #RubyOnRails
[17:39:42] one_zero: has joined #RubyOnRails
[17:40:07] KeyJoo: has joined #RubyOnRails
[17:50:14] Dimik: has joined #RubyOnRails
[17:52:36] quazimodo: has joined #RubyOnRails
[17:53:23] dangerousdave: has joined #RubyOnRails
[18:02:27] xco: has joined #RubyOnRails
[18:21:20] chouhoulis: has joined #RubyOnRails
[18:23:25] moei: has joined #RubyOnRails
[18:25:33] emmalj: has joined #RubyOnRails
[18:27:06] emmalj: Hi. Thanks for rule #14!
[18:31:09] dminuoso: nzst: Sorry had to hop on a train earlier.
[18:31:40] dminuoso: nzst: Would I be right in assuming that you are producing a non-trivial amount of data with jbuilder on that request?
[18:31:45] dblessing: has joined #RubyOnRails
[18:33:19] truenito: has joined #RubyOnRails
[18:35:45] SteenJobs: has joined #RubyOnRails
[18:37:22] fcser_: has joined #RubyOnRails
[18:39:30] mikecmpbll: has joined #RubyOnRails
[18:40:42] kies: has joined #RubyOnRails
[18:41:50] uks: has joined #RubyOnRails
[18:42:38] hahuang65: has joined #RubyOnRails
[18:50:27] fragamus: has joined #RubyOnRails
[18:51:44] orbyt_: has joined #RubyOnRails
[18:53:01] nzst: dminuoso: Correct.
[18:53:14] nzst: with jbuilder partial calls, as well
[18:53:59] dminuoso: nzst: That is what is likely so expensive.
[18:54:05] dminuoso: jbuilder with partials are incredibly punishing
[18:54:30] nzst: That's what I'm discovering after researching. It's put me in a bit of a bind
[18:54:42] dminuoso: nzst: Do you need better performance all over, or just selectively in a few spots?
[18:55:03] dminuoso: nzst: Also its backed up by stackprof now that I look at it by th eway
[18:57:46] nzst: dminuoso: Well, I don't have a gameplan with regards to better performance all over or selectively, at this point. There's an #index call made in 2 spots of the application that this slowness is apparent
[18:58:13] dminuoso: nzst: You will not get better performance than using vanilla to_json
[18:58:29] dminuoso: There are some simple tricks to gain reusability of certain object portions
[18:59:09] nzst: I'm all ears. I'm not sure how to use to_json as the jbuilder is heavily used as a template and not a basic object serialization
[18:59:13] dminuoso: Here we use AMS with to_json on some things where I need absolutely maximum performance (suggestions as you type)
[18:59:39] dminuoso: ActiveModelSerializers
[19:01:23] dminuoso: It's generally much faster than jbuilder (Im guessing this has to do with the fact that AMS does not use views).
[19:06:40] Technodrome: has joined #RubyOnRails
[19:10:41] dminuoso: nzst: https://eval.in/894898
[19:11:02] dminuoso: nzst: This shows a very simple way to organize fast serializers (which you can easily reuse)
[19:16:45] dminuoso: https://eval.in/894902 rather I suppose
[19:22:57] Technodrome: has joined #RubyOnRails
[19:23:35] justrying: has joined #RubyOnRails
[19:24:01] debclair: has joined #RubyOnRails
[19:27:27] nzst: dminuoso: oh, this is interesting, thanks!
[19:29:38] nzst: dminuoso: So, what you're suggesting and I'm thinking is I have to build a custom module for serialization and control logic to build this mountain of json and move away from jbuilder.
[19:30:15] dminuoso: nzst: Yeah. This is also what AMS does (it just adds a lot more rails-type of magic to reduce efforts).
[19:37:01] chouhoulis: has joined #RubyOnRails
[19:39:25] dinoangelov: has joined #RubyOnRails
[19:48:56] ur5us: has joined #RubyOnRails
[19:50:34] nzst: dminuoso: You might not have enough information, but do you think I'd be able to use AMS or something similar?
[19:51:27] dminuoso: nzst: Im careful to recommend AMS because of the state its in. You definitely can use it.
[19:51:49] dminuoso: But if performance is critical, you probably should look into constructing json with a similar pattern as I showed.
[19:52:01] dminuoso: AMS is still faster than jbuilder on a factor of about 10x.
[19:56:46] Technodrome: has joined #RubyOnRails
[20:03:16] xco: has joined #RubyOnRails
[20:04:02] xco: has joined #RubyOnRails
[20:05:18] hgost: has joined #RubyOnRails
[20:13:05] simmerz: has joined #RubyOnRails
[20:16:51] ule: If I understood well, ActiveRecord::Base.establish_connection will close the current connection and create a new one. Do you see any problem on doing that? I'm not sure if it's possible to just keep 2 connections active and just switch between them using connection_handler
[20:17:10] ule: I need to switch between production_db to slave_db on some specific routes (reports)
[20:22:04] FrostCandy: has joined #RubyOnRails
[20:23:24] ule: Looks like this method is not pretty common instead. Its not everyone that has to deal with > 1 database connections
[20:27:40] Technodrome: has joined #RubyOnRails
[20:28:38] elcontrastador: has joined #RubyOnRails
[20:33:41] orbyt_: has joined #RubyOnRails
[20:40:10] Technodrome: has joined #RubyOnRails
[20:40:24] ivanskie: has joined #RubyOnRails
[20:44:41] alfiemax: has joined #RubyOnRails
[20:49:35] [Butch]: has joined #RubyOnRails
[21:05:34] arBmind: has joined #RubyOnRails
[21:10:27] ArTiSTiX_: has joined #RubyOnRails
[21:12:56] nzst: dminuoso: thanks again for the path forward, stackprof is great. I'm off :)
[21:12:58] nzst: has left #RubyOnRails: ("Using Circe, the loveliest of all IRC clients")
[21:23:46] dminuoso: ActionController::InvalidCrossOriginRequest in StreetsController#index
[21:23:48] dminuoso: What the actual?
[21:24:14] BloodyMer: has joined #RubyOnRails
[21:24:55] dminuoso: Mmm, this is interesting. It happens when I use localhost rather than my loopback address.
[21:25:40] dminuoso: Although no. http://[::1]:3000/streets.js
[21:43:11] SteenJobs: has joined #RubyOnRails
[21:45:10] xco: has joined #RubyOnRails
[21:51:19] xco: after creating a migration like this https://gist.github.com/xcobar/42a84936b551f6fa36e1073362fbb0f3 to rename a column, and after i decide to now remove that column, is creating another migration to remove the column the best way to do it? or i can just edit the same file and say remove_column, :old_column_name
[21:52:53] fragamus: has joined #RubyOnRails
[21:54:13] timdotrb: has joined #RubyOnRails
[21:59:03] mtkd: has joined #RubyOnRails
[22:03:39] danielsousaio: has joined #RubyOnRails
[22:06:42] danielsousaio: Hey, I found out that a PORO that extends ActiveModel::Naming doesnt humanize model_name plurarly properly.
[22:06:54] danielsousaio: Something.model_name.human(count: :many) # => "Something"
[22:07:01] dminuoso: ACTION pokes Radar
[22:07:06] dminuoso: Why don't we have that factoid?
[22:07:17] danielsousaio: Found the reason why here: https://github.com/rails/rails/blob/5473e390d362755125d2f47b64ef0a135f2fe111/activemodel/lib/active_model/naming.rb#L177
[22:07:46] dminuoso: danielsousaio: Which one does it not respond to? lookup_ancestors or i18n_scope ?
[22:07:51] danielsousaio: I'm wondering why would such behaviour exist? What is the though process behinds returning just @human if the class doesn't implement those?
[22:08:37] danielsousaio: Needs ActiveModel::Translation also to make it work properly
[22:09:28] dminuoso: danielsousaio: It doesn't technically.
[22:11:07] danielsousaio: dminuoso: What do you mean?
[22:11:22] dminuoso: danielsousaio: lookup_ancestors is needed to find the object path inside i18n files, and i18n_scope gives a default scope.
[22:11:35] jarnalyrkar: has joined #RubyOnRails
[22:11:36] dminuoso: danielsousaio: So just provide those two methods, and you're good. The real problem is that this is not well documented it seems.
[22:11:59] danielsousaio: Heres a gist: https://gist.github.com/danielsousaio/751ca3c9372ed215195b00c0c950caca
[22:12:07] danielsousaio: Yes I didn't see it documented on ActiveModel::Naming
[22:12:57] danielsousaio: Is it wrong to think that on the first PORO it should just error instead?
[22:13:25] danielsousaio: Trying to understand the reasoning behind such design
[22:18:05] Radar: GOOD MORNING
[22:18:24] Radar: dminuoso: what should that factoid do?
[22:18:47] helpa: Please provide a Minimal, Complete, and Verifiable example of your problem to assist us - http://stackoverflow.com/help/mcve
[22:18:51] Radar: dminuoso: ^ ?
[22:19:15] baweaver: ACTION thought he was going for MVC
[22:20:23] dminuoso: danielsousaio: https://github.com/rails/rails/commit/9fbb2c571b65e0501bf3570a3d49e553a9ae39c1
[22:20:55] dminuoso: (Ignore that its in a different place, it was moved a few times over the years)
[22:21:57] SteenJobs: has joined #RubyOnRails
[22:22:22] dminuoso: Im not well versed in rails, but this does look like some hacky fix. The behavior you are experiencing does not look like it was intended.
[22:23:14] dminuoso: danielsousaio: Though there is something good about getting a human name, no matter whether you have supplied the necessary i18n lookup information.
[22:23:26] danielsousaio: Updated the gist in the meanwhile to make it clearer.
[22:23:51] danielsousaio: dminuoso: Didn't expect a human without options considered to be returned though
[22:23:54] dminuoso: danielsousaio: Please do make a PR :)
[22:24:47] dminuoso: danielsousaio: Well, it seems to have done so that error_messages_for could humanize even if the objects class was not a rails object.
[22:25:21] dminuoso: And I suppose its reasonable to assume that if you include ActiveModel::Naming (or the then-equivalent), that it must somehow be humanizable.
[22:26:06] dminuoso: Radar: Oh I was not aware of that one. Dunno if I can remember that.
[22:27:00] danielsousaio: dminuoso: Agreed. That's what I expect from reading the api http://api.rubyonrails.org/v5.0/classes/ActiveModel/Naming.html
[22:28:17] dminuoso: danielsousaio: Care for making a simple modification to just make note to provide those two methods (or include the other module you mentioned) for i18n lookuo?
[22:28:38] dminuoso: Such PRs are always appreciated.
[22:29:54] danielsousaio: dminuoso: Of course! Will try my best, not an expert :)
[22:30:12] Radar: dminuoso: train your brain
[22:30:41] dminuoso: danielsousaio: http://edgeguides.rubyonrails.org/api_documentation_guidelines.html
[22:31:32] danielsousaio: dminuoso: Appreciated
[22:40:36] Technodrome: has joined #RubyOnRails
[22:44:29] twilling: has left #RubyOnRails: ()
[22:55:46] SteenJobs: has joined #RubyOnRails
[23:10:50] hopsoft: has joined #RubyOnRails
[23:12:52] jphase: has joined #RubyOnRails
[23:17:57] jphase: has joined #RubyOnRails
[23:29:32] jarray52: has joined #RubyOnRails
[23:30:30] jphase: has joined #RubyOnRails
[23:38:05] hahuang65: has joined #RubyOnRails
[23:39:01] jphase: has joined #RubyOnRails
[23:39:59] jphase: has joined #RubyOnRails
[23:41:33] aclark: has joined #RubyOnRails
[23:46:18] hopsoft: My company has been struggling with full stack front-end SPA frameworks within Rails 5.1. Our current path has been a never ending transition from server-rendered Rails, to a home grown micro JavaScript framework, to some React, to full React/Redux (still in progress). The amount of code, complexity, time, & people involved has increased a lot; though, we don't have any new features to show for it. We seem to have strayed from the
[23:46:18] hopsoft: Rails ethos of empowering small teams. We've been experimenting with ways to reclaim our productivity & would love feedback on this particular demo of something we're trying out on some of our internal tools. Mostly, looking for validation or reasons it's likely a bad idea. https://github.com/hopsoft/cable_ready_todomvc
[23:57:39] Immune: has joined #RubyOnRails