#RubyOnRails - 22 March 2018
« Back 1 day Forward 1 day »
[06:55:09] dminuoso: So! This is what a casual day with webpack looks like: https://gist.github.com/dminuoso/4def6dfb47dbd1b4a5ff2543e70305ff
[07:14:06] syndikate: Thing was the default settings had some issues couple of weeks ago. I was not able to boot up a new app. I did not get time to check again, not sure if it got fixed
[07:32:25] morfin60: can i somehow build WHERE locale=:locale AND (title != "" AND description != "" AND product_type != "") in Rails?
[07:43:34] timdotrb: Evening, all. How does one change the name of a model in an error message? This is what I have currently, but it’s not changing anything (the model name nor the attribute): https://gist.github.com/willc0de4food/b193d33936407e342be0b7232d447e0e
[07:46:08] dminuoso: timdotrb: I usually plug the gem `i18n-debug` in, and see which translations are looked up.
[07:49:02] morfin60: joins(:translations).where.not(conditions).where("locale = :locale", locale: translation)
[07:49:19] timdotrb: dminuoso: Updated gist with i18n-debug output. It looks like I may need to nest the en.yml differently?
[07:50:40] morfin60: SELECT "interiors".* FROM "interiors" INNER JOIN "interior_translations" ON "interior_translations"."interior_id" = "interiors"."id" WHERE ("interior_translations"."interior_type" != "") AND ("interior_translations"."title" != "") AND ("interior_translations"."description" != "") AND (locale = 'ru') LIMIT 11
[07:52:30] timdotrb: dminuoso: in this case, I’m attempting to upload a PDF when a CSV is required. The field on the model is also called csv
[07:53:30] dminuoso: If there are spots that need a different translation, use an explicit i18n lookup for a different key.
[07:54:29] timdotrb: dminuoso: that’s not a bad idea. At the time I created it, csv made sense to me, but now in practice (seeing errors), it does not. Btw, updated gist with email_list model
[07:59:58] timdotrb: dminuoso: although that doesn’t solve my base problem of changing the name of the model in the error message (it says “email_list”, I want it to say “SOI list”). It’s weird; it finds the text SOI List, but does not display it. I’ve updated my gist with the new output and new en.yml
[08:05:59] dminuoso: timdotrb: Can you gist the code that generates the error message for completeness?
[08:06:38] timdotrb: <h2><%= pluralize(@email_list.errors.count, "error") %> prohibited this email_list from being saved:</h2>
[09:05:24] Cork: how do one validate the presence of a boolean attribute (default value is nil) validate_presence doesn't allow false
[09:50:19] timdotrb: Sigh. Here’s a new issue.. I’m telling paperclip to create an image that’s 150x150# and it’s creating one with a variable width and 150 height
[09:50:41] timdotrb: is # not the sign I should be using? I want the image to be 150 wide, and to crop the height to 150
[10:15:25] pavelz: hi i have a q: what is a helper -> users_path(id) vs user_path(id) latter is show, which is former ?
[12:44:28] CGibsonmm: I have a question about factory_bot, I have a 1:1 association for my user and user_profile model, and on user sign up it also call create on the user_profile, how can i reflect that in my factory generation, i keep ending up with a empty user_profile
[14:48:55] Torrone: I don't want anybody to access them by typing their address in the browser window
[14:49:45] dminuoso: Torrone: If people figure out the address, it means they are skilled enough to open the dev tools. If they are smart enough to do that, they can write the machinery to automate it anyway.
[14:56:19] Torrone: dminuoso, I'm settling for just checking the existence of a request.headers['HTTP_X_CSRF_TOKEN']
[15:05:35] Inside: So... when using react-rails - is there any way to generate a form server side and stick it into the component somehow :|
[15:06:52] context: whats the point of using react if you are just going to generate raw html on the server side
[15:07:52] context: and... sure why not... just pull the form from the server and put it into the form dom
[15:22:15] Inside: so this is my use case: i have a form, a web socket connection to a locally hosted windows service, and a status log thing
[15:23:43] Inside: so .. someone visits the page, it makes a connection to the local service to pull in printer information, then someone fills in some data & hits submit, the rails server generates some raw ZPL printer commands, and then the web page pushes the ZPL commands to the printer over the websocket to the service which uses FFI to access the winapi to print labels
[15:24:10] Inside: really effing retarded, but try making a web application print over a Text/Generic printer ;)
[15:44:54] Inside: I've only done a few react components so far and it was a very "whoamg this is so cool" experience
[15:45:21] dminuoso: Inside: Imagine you didn't have State at all - that's when you begin to understand what React is for
[15:45:38] dminuoso: (And I have written entire applications that dont have any local react state whatsoever)
[16:05:10] Inside: I've used something called 'MPI' which is a lisp-like language, but that was not a fun language to use..
[16:32:19] jlebrech: i'm on Rails 5.0.0 and when I do ActionController::Parameters.permit_all_parameters = true I will still complain about an unpermitted parameter but still allow access to it.
[16:52:35] mauro1254: Hi folks, I have a question concerning database migrations. I'm on mysql. Why ins't there any options related to the collation for tables created through Rails 5.1 in schema.rb?
[18:08:46] MrCrackPotBuilde: if i was to build my own production server could i do it with justt apache2 puma rvm ruby rubyonrails and node.js ???
[18:09:35] MrCrackPotBuilde: configure the root file system if the app as the place to load eg default apache is /var/www/html
[18:10:11] MrCrackPotBuilde: so im guessing i need to route puma through apache but get it to auto run on boot ??
[18:16:34] fryguy: you'll want some sort of real webserver in front of puma to handle real internet traffic
[18:20:48] Inside: you said you don't want to mod the pi... is this just something that's going to have one user? (you?)
[18:21:57] Sylario: Anyway regarding the initial question, RVM (and RBenv) allow you to manage the ruby install(multiple versions, and easier updates), Puma does not need Apache, Apache need passenger, and whatever web server you choose you configure the app and it's path using the configuration format of your server of choice.
[18:23:16] MrCrackPotBuilde: Ive gone with apache passenger as everything else is already set up haha
[18:23:19] Inside: At work my stuff is hosted on a centos machine with 4gb of ram and 2 cores.. using nginx/passenger
[18:24:10] Omnilord: And don't forget you can get SSL for free with Let's Encrypt. Not sure how to configure that with Puma, but it slides right in with Apache or Nginx.
[19:01:21] jomitsch: hey all! My team and I are having a pretty frustrating server hang issue in our development environment. We are discussing it on our community forum here https://community.theforeman.org/t/dev-server-hangs-on-code-change/8184/11?u=john_mitsch - I think I narrowed it down to an issue with ActionDispatch::Reloader, but would like to confirm I am making a correct assumption here? Details on how I came up
[19:01:23] jomitsch: with this are here https://paste.fedoraproject.org/paste/EBixCIbRwRimCgbESLkxnA and we are using 5.1.4
[19:53:17] jomitsch: Inside: yes, but apparently another dev tried disabling it and still saw the server hang issue
[21:13:32] jesson: anyone have suggestions for the best way to relearn rails? I haven't touched it in more than a year and a half but my new interview is all rails.
[21:14:05] jesson: I've already tried reading docs i want to create a project but dont know what to make
[21:19:26] akofink: jesson: you could contribute to an existing open source Rails project! i.e. (Rails 5.1) https://github.com/theforeman/foreman
[21:20:21] harrycs: I think I'm spacing on something obvious. Do I need to manually sanitize all user input in Rails 5? I have a user-inputted `note` column - I can just pass a param from the controller directly to the model, right?
[21:22:00] jesson: you should never use raw input, always check for htmlspecialchars in case of injection
[21:22:05] akofink: harrycs: you can't call `.to_h` on ActionController::Parameters unless their permitted
[21:23:46] akofink: if you really want to be dangerous (don't do this in production!!) call params.permit!
[21:24:53] harrycs: I mean, if I permit a param intentionally, do I need to sanitize it? say, for example, I want a user to be able to submit a tweet or something
[21:25:04] harrycs: do I need to specifically sanitize the tweet text, or does rails automagically do it?
[21:26:40] havenwood: harrycs: Rails 4.2 introduced a new sanitizer. Make sure to use recent sources.
[21:30:50] havenwood: jesson: I'd suggest going to 2.4.3 at least immediately. 2.5.0 is the latest stable version (which maaay segfault a teeny tiny bit)
[21:31:24] jesson: The exercise uses Ruby on Rails 5.1 and was built with Ruby 2.4 (any minor version of 2.4 will work—please have this installed ahead of time). The provided tests are in minitest and use standard YAML-formatted Rails fixtures.
[21:40:21] spohnz: If I save a static list in my model. I.E STATUS = ["Resolved","Blocked","In Review"] to show with each record in my index. How do I show it as a drop down?
[21:42:28] havenwood: spohnz: A constant is a nice way to have a static list. It's a common practice to freeze constants, just add a `.freeze` to the end of the Array.
[21:43:40] havenwood: spohnz: The FormOptionsHelper docs should show how to do a dropdown collection select.
[21:52:34] jesson: RVM PATH line not found for Bash or Zsh, rerun this command with '--auto-dotfiles' flag to fix it.
[21:55:26] havenwood: jesson: It add the `source RVM_SCRIPT_HERE` line to your dotfile so RVM loads when you open your terminal.
[21:57:21] havenwood: You can just put it in your dotfile yourself, bash for example: echo "source $HOME/.rvm/scripts/rvm" >> ~/.bash_profile
[22:07:04] dgsan: Anybody have insight into choosing strong_password vs. password_strength, or is there something else widely used now?
[22:40:36] Inside: jomitsch-afk: I develop on windows, but use a shared drive with my virtualbox instance. SPring doesn't like shared folders so I have to do config.file_watcher = ActiveSuppoer:FileUpdateChecker
[22:48:49] conceivably: Hello. Why does the shallow: true option not apply to :index and :new when nesting routes? What is the correct way to achieve the same result then?
[22:50:33] conceivably: This seems so odd as it pretty much defeats the purpose of using 'resources' in conjunction with 'shallow: true' since you then always have to manually specify above mentioned routes.
[23:06:50] spohnz: me again, I am having a bad time with this static list. I didn't use the .freeze as it looked too difficult. so my list is in the model with STATUS as the variable. I keep getting errors when trying to call it in the _form