#RubyOnRails - 08 February 2019
« Back 1 day Forward 1 day »
[00:25:10] bruul: i've got a rudimentary blog posting thing after following a tutorial (https://guides.rubyonrails.org/getting_started.html#rendering-partial-collections) and i've got an Article model that has many Comments attached to it, and the Article#show has `<%= render @article.comments %>` but this ends up rendering all the comments *plus* one blank comment that doesn't exist. it also shows a blank comment on an
[00:25:12] bruul: article that has no comments. how do i get it so that i don't get an extra empty comment partial? my repo is here (https://gitlab.com/cptchuckles/hello_rails)
[00:42:50] havenwood: bruul: Each time you run `@article.comments.build`, it creates a single, non-persisted Comment.
[00:49:26] bruul: so this is happening because i put my form ahead of my render call... i could fix this by placing the form at the bottom
[01:13:26] yoshie902a: https://stackoverflow.com/questions/54584687/undefined-number-to-currency-inside-a-helper-are-helpers-for-views-or-controlle
[01:14:10] yoshie902a: is number_to_currency automatically available in helpers, or do I need to include them?
[01:27:57] havenwood: yoshie902a: The #number_to_currency method takes an argument that is the number you want to format as a currency.
[01:59:25] yoshie902a: Is there a function to help display “Last signed in” messages, so given a date, the output would be “1 day,”, 2 weeks, 1 month,?
[06:37:21] haxx0r: i've copied some templates from an old production to throw them into a new project. they include some german characters 'öß' and other. however, now the templates won't work. Encoding::UndefinedConversionError "\xC3" from ASCII-8BIT to UTF-8. i use ATOM as my texeditor and the encoding for the document is UTF-8. i'm confused
[06:40:09] catbusters: Do you have `# encoding: utf-8` set in the page? It's most likely not the cause, but couldn't hurt to try
[06:50:34] haxx0r: yeah, there are plenty of other gems that are super helpful for working against APIs, scraping data
[06:52:20] catbusters: https://github.com/httprb/http is what I've been using and they claim to have been inspired by requests
[08:34:26] BrianJ: So I upgraded my rails 5.2.1 to 5.2.2 running in api mode and all of sudden my cors initializer: Rails.application.config.middleware.insert_before 0, Rack::Cors initializer at https://gist.github.com/bjensen/90f8b6c6f206a07c4e4f323bdd65a78a is giving me errors a FrozenError can't modify frozen Array. Is there a different way to setup cors now?
[12:09:34] xco: : I know there’s word for it but for some reason i can’t remember, what’s the word for when you’re testing some application and for each test a random result is returned, example say you have a rails app and for each refresh of the page a random error (different from the previous) shows up?
[13:42:21] thoraxe: so, weird question. i see how to use .order for multiple fields (eg: order by 1 then by 2) but I am trying to do "order by the older of 2 dates" and not really understanding how to do it
[13:44:19] fox_mulder_cp: thoraxe: hm? ose filter with date before and date after and order creteria after
[13:46:12] fox_mulder_cp: or you take random 10 unsorted positions, filter first 10 and than order it by date
[13:47:34] IGnorAND: Anyone use https://github.com/lynndylanhurley/devise_token_auth? I don't seem to be getting a access-token on a new request. Am I missing something in my controller?
[13:47:37] fox_mulder_cp: all funstions called on results based on previous functions. from left to right
[13:51:35] fox_mulder_cp: thoraxe: if you read classic sql query from any engine you see - select date, name from table where date > bla and date < now order by date limit 10
[17:24:58] mwlang: I’m looking into building a new Rails 5 app that needs to be multi-tenanted. Thus, apartment gem comes to mind, but also perhaps the better route in this day and age is to dockerize the rails app and spin up docker images per tenant/domain served instead of building logic into the app itself.
[17:25:28] mwlang: Has anybody recently weighed pros and cons of the two approaches and have some insights or links to share?
[18:33:25] mwlang: havenwood: Ah yes, radar was writing that book when I was last hanging out around these parts....
[18:34:00] mwlang: there will be some shared model data — mostly in the form of templates they can choose to rapidly launch their sites.
[18:41:28] mwlang: but it’ll probably grow slowly enough that I do not have to worry about it until much later in the life-cycle.
[18:44:20] mwlang: the way I see it…if using something like apartment, can have many, many “small tenants” on one server and one deploy updates many at once.
[18:45:27] mwlang: the tenants are law firms, for reference….so you can probably imagine most of these sites will only draw local traffic for local business in their geographical areas…not like a national company with a million page hits a month.
[18:48:03] mwlang: the concern there is density. that is, how many “tenants” can I run on one server — i.e. how many docker containers per server.
[18:48:37] mwlang: intuition is telling me, an apartmentized rails app would have much higher density than I can achieve with docker.
[18:49:56] mwlang: truth be told, more concerned about the ability of a small team to handle large number of tenants effortlessly.
[18:52:22] havenwood: mwlang: So options are 1) single app with single db, 2) single app with multiple dbs, 3) multiple apps with multiple dbs?
[18:53:45] mwlang: one concern I have with multiple firms in one database…experience with current clients tells me they’re often targeted for hacks.
[18:54:27] mwlang: so I’m already thinking “sharding” (in the loose sense of the word) for spliting up tenants across servers
[18:55:13] mwlang: I just don’t know *why* lawyers are hated by so many people…. (he says sarcastically...)
[18:56:16] havenwood: 1. is the simplest to maintain and administrate, with the downside of some app complexity for multi-tenancy and having to scale them all together for both app and db resources
[18:58:15] havenwood: I guess we didn't mention multiple apps, with one db - but that one isn't very attractive.
[19:00:03] mwlang: the more I think about it, I think best to start at #2 with ability to introduce #3 for scaling purposes.
[19:03:20] mwlang: dumb question: selling front-end and tenant front-end all in one rails app or split ‘em out?
[19:06:23] havenwood: If you had a subscriptions team that worked on the sales app, and another team that worked on the tenants app, I'd say two apps with APIs.
[19:06:28] mwlang: The selling frontend will control setting up the subdomains and controlling whether to show tenant’s content based on whether subscription is paid up or not.
[19:08:06] mwlang: it is simple enough to control the tenanted app with API and use background jobs to setup/suspend/teardown tenants.
[19:20:36] jstrong: Hi all. I have a bit of an interesting issue. Perhaps some of you can help me figure out how to best achieve this. We have some mission-critical models that we want to be *impossible* to update outside of the context of a particular interface defined (i.e. an “Updater” object) that can do all the logging, validation, constraints, queries etc necessary
[19:21:43] jstrong: Subscription is the model in question here. This would block any calls to .save, .update, .update_attributes etc on the “protected model” and instead *force* people to use the “Updater” class
[19:22:22] jstrong: the only issue here is that the Updater can’t actually see the private method (same if it’s set to protected), and I’m not sure how to structure the Updater class so that it has access to those methods
[19:37:02] mwlang: Let subscription class instantiate an updater class and call some general function, say #perform or #update! or whatever it’s going to be for the updaters.
[19:37:38] mwlang: updater itself then calls it’s own private methods with whatever parameters the subscription class instantiated it with or passed on the call to perform said action.
[19:37:41] jstrong: mwlang: when the subscription class instantiates an updater class, would it pass the protected save and protected update methods directly to that instantiated class?
[19:38:23] jstrong: mwlang: I don’t think that works. The updater doesn’t explicitly have access to the protected methods on the ActiveModel object
[19:52:05] jstrong: This works: https://gist.github.com/laspluviosillas/b83e28c233949d5b5bc531b9e1baf356
[21:19:48] cagmz: Having issues with my Docker build using an incorrect version of Bundler. Rather than using this solution ( https://discuss.circleci.com/t/using-bundler-2-0-during-ci-fails/27411/3 ) , can I follow these instructions to automatically use the Gemfile.lock version of Bundler? https://bundler.io/blog/2019/01/03/announcing-bundler-2.html
[21:22:23] IGnorAND: I think rails is sending a content didnt change but I need the headers to get sent. Is there a way to force that?
[21:31:40] havenwood: IGnorAND: How about just?: source <(export BUNDLER_VERSION="$(tail -1 Gemfile.lock | xargs)")
[21:33:00] IGnorAND: havenwood: I made a --api app in rails. When logging in with my vuejs app I seem to get an authentication token. When doing subsecquent requests I do not. With Curl, postman etc it seems to act as expected. Not sure where to look where its going wrong. Expecting maybe puma decides to just get the data from cache and not send the header