« Back to channel list

#RubyOnRails - 05 November 2018

« Back 1 day Forward 1 day »
[00:07:51] tdy: has joined #RubyOnRails
[00:15:11] kapil____: has joined #RubyOnRails
[00:32:17] mangold: has joined #RubyOnRails
[00:41:39] sevenseacat: has joined #RubyOnRails
[00:47:44] albus: has joined #RubyOnRails
[00:48:53] albus: What's the right way to create views for related models? I know how to create a form/view for a single model, but what about related models?
[00:49:31] albus: e.g. I have a House model, and there are many ExpenseItem for each House, if I wanted to create a table that's got a list of ExpensItems related to a house, how would I do that?
[00:49:38] albus: is there a tutorial/docs somewhere on how to do that?
[00:50:43] albus: an ExpenseItem has a name, cost, and date
[00:50:54] albus: so I want to have a table of ExpenseItems with those attributes as columns
[00:51:12] albus: and then a button/link to click that will let me add a new expense item
[00:52:43] albus: I saw there's a railscast episode on nested_attributes_for but idk if that's what I need
[00:52:55] weaksauce: has joined #RubyOnRails
[00:54:06] sevenseacat: watch it and see :)
[01:17:41] cagomez: has joined #RubyOnRails
[01:19:20] cagomez: has joined #RubyOnRails
[01:37:54] SleepWaka: has joined #RubyOnRails
[01:38:05] SleepWaka: has left #RubyOnRails: ()
[01:38:31] SleepWaka: has joined #RubyOnRails
[01:39:26] SleepWaka: Hi - I'm looking for some help with using Capistrano for deployment, if anyone can assist please PM.
[01:39:45] orbyt_: has joined #RubyOnRails
[01:44:02] cagomez: has joined #RubyOnRails
[01:48:07] roshanavand: has joined #RubyOnRails
[01:58:05] SleepWaka: has left #RubyOnRails: ()
[02:03:03] mangold: has joined #RubyOnRails
[02:07:16] jetchisel: has joined #RubyOnRails
[02:09:23] cagomez: has joined #RubyOnRails
[02:20:32] Saukk: has joined #RubyOnRails
[02:20:47] cagomez: has joined #RubyOnRails
[02:32:23] jane_booty_doe: has joined #RubyOnRails
[02:36:45] jane_booty_doe: what would cause flash[:foo] to not persist on redirect while flash.now[:foo] is working fine w/ render
[02:37:38] sevenseacat: how do you know its not persisting?
[02:37:47] jane_booty_doe: i inspected the flash hash and its empty
[02:37:53] sevenseacat: can you show us?
[02:38:42] sevenseacat: you might be doing something like a double redirect instead
[02:43:42] jane_booty_doe: sevenseacat, i set up a new controller just to test it. using the index to either flash/redirect or flash.now/render the home page path or view
[02:44:01] sevenseacat: can you show us?
[02:44:12] sevenseacat: describing code is never as useful as seeing it
[02:45:20] jane_booty_doe: the test controller?
[02:45:37] sevenseacat: however you're seeing that there's a bug.
[02:48:53] jane_booty_doe: sevenseacat, https://gist.github.com/jbd70/ba3d2265c456eeb937a7d59c589ce2b0
[02:49:17] jane_booty_doe: comments are output of `= debug flash`
[02:50:22] sevenseacat: ok so you're setting a flash var and then redirecting. where's the code of where you're redirecting to?
[02:52:37] jane_booty_doe: well i'd need to put up all the layout partials to show it i guess. maybe ill combine them
[02:53:22] sevenseacat: or stick your debugging code in the controller and show the controller code :)
[02:54:55] jane_booty_doe: the welcome controller is just an empty index method that renders a markdown page
[02:55:40] sevenseacat: you're not helping matters here
[02:58:16] jane_booty_doe: what controller should i debug?
[02:58:26] sevenseacat: the one that is showing you the bug
[02:58:32] sevenseacat: I don't know what controller that is
[02:58:37] sevenseacat: its your codebase :)
[02:58:47] roshanavand: has joined #RubyOnRails
[03:00:29] jane_booty_doe: i think its being caused somewhere else in the stack, idk where. but it happens on every page
[03:01:26] sevenseacat: well if you can't demonstrate that there's an issue, I'm not sure how anyone can help you fix it
[03:02:05] za1b1tsu: has joined #RubyOnRails
[03:05:44] jane_booty_doe: it doesn't look like you can debug the flash object in the controller
[03:06:10] sevenseacat: sure you can.
[03:07:16] jane_booty_doe: ah nvm. you just can't w/ flash.now
[03:07:46] jane_booty_doe: `flash.inspect` in the controller was "#<ActionDispatch::Flash::FlashHash:0x00007f7293158ee0 @discard=#<Set: {}>, @flashes={}, @now=nil>"
[03:08:53] jane_booty_doe: i kind of think this is related to a gem
[03:09:51] jane_booty_doe: i just dont know where to start w/troubleshooting this because there's so many things that could cause it
[03:17:41] jetchisel: has joined #RubyOnRails
[03:30:55] quazimodo: has joined #RubyOnRails
[03:37:16] quazimodo: has joined #RubyOnRails
[03:48:12] roshanavand: has joined #RubyOnRails
[04:01:49] mangold: has joined #RubyOnRails
[04:09:07] braincrash: has joined #RubyOnRails
[04:20:34] syndikate: Anybody upgraded to rubicon 0.6 on a rails project and faced any issues?
[04:33:03] quazimodo: has joined #RubyOnRails
[04:46:32] jane_booty_doe: sevenseacat, session_store initializer was the problem
[04:46:53] jane_booty_doe: had it set to this for some reason `Rails.application.config.session_store ActionDispatch::Session::CacheStore, :expire_after => 20.minutes`
[04:48:38] jane_booty_doe: that one line caused me so many problems lmao
[04:49:09] sevenseacat: glad you got it fixed :)
[04:56:05] Liothen: has joined #RubyOnRails
[05:15:43] jasmith: has joined #RubyOnRails
[05:31:05] quazimodo: has joined #RubyOnRails
[05:31:18] quazimodo: has joined #RubyOnRails
[05:48:34] cgfbee: has joined #RubyOnRails
[06:39:56] mangold: has joined #RubyOnRails
[06:42:48] conta: has joined #RubyOnRails
[06:43:07] MrCrackPotBuilde: has joined #RubyOnRails
[06:44:25] MrCrackPotBuilde: has anyone here ever experienced errors in the application build when posting to heroku if your using Rails.applicatoin.credentials.database[:username] inside your database.yml file
[06:45:42] sevenseacat: why would you use that if you're using heroku? it sets all that up for you
[06:46:06] MrCrackPotBuilde: because the app needs it for development
[06:46:24] sevenseacat: ...you might have to explain your error then
[06:47:40] MrCrackPotBuilde: well as you know database yml comes with 4 catagories. Default development test production. Heroku already has elements that you can not manipulate because of how it stores its creds.
[06:48:08] sevenseacat: a gist of the error would be great.
[06:48:09] MrCrackPotBuilde: so inside development and test i only add the rails.application.credentials
[06:48:31] sevenseacat: instead of a long-winded description of it
[06:49:15] MrCrackPotBuilde: https://gist.github.com/scope2229/4fa0bb72dac24c687945e92b828860ae
[06:50:07] MrCrackPotBuilde: if you add <%= Rails.application.credentials.dbc[:dbu] %> etc to username and password when you then push to heroku it fails
[06:50:35] MrCrackPotBuilde: right now there empty because heroku doesnt like it and the application builds
[06:50:43] sevenseacat: you don't need to specify any db config for production
[06:50:44] MrCrackPotBuilde: but why is it using development in the first place
[06:50:56] MrCrackPotBuilde: heroku does it all for you
[06:50:59] sevenseacat: so again, a gist of the error would be great
[06:52:05] MrCrackPotBuilde: Detecting rails configuration: ###### WARNING:Detecting rails configuration failed set HEROKU_DEBUG_RAILS_RUNNER=1 to debug
[06:52:34] MrCrackPotBuilde: the error is down to rails.application.credentials
[06:52:53] sevenseacat: please gist the full error. this really is the last time I'll ask.
[06:54:31] paranoidaditya: has joined #RubyOnRails
[07:02:21] ariedler: has joined #RubyOnRails
[07:39:21] srinidhi: has joined #RubyOnRails
[07:45:55] DTZUZO: has joined #RubyOnRails
[08:04:14] DoubleMalt: has joined #RubyOnRails
[08:15:43] za1b1tsu: has joined #RubyOnRails
[08:16:19] i8igmac: has joined #RubyOnRails
[08:18:29] srinidhi: has joined #RubyOnRails
[08:41:16] srinidhi: has joined #RubyOnRails
[08:41:27] Sylario: has joined #RubyOnRails
[08:44:48] JamieD: has joined #RubyOnRails
[09:03:21] ariedler: has joined #RubyOnRails
[09:09:59] whysthatso: has joined #RubyOnRails
[09:17:32] lxsameer: has joined #RubyOnRails
[09:24:07] hd1: has joined #RubyOnRails
[10:04:52] Psy-Q: so now i'm using after_initialize to set some defaults in a model instead of initialize as recommended in some places. how can i force client code to provide a specific argument, though? for that i'd still need a constructor, no?
[10:10:55] mangold: has joined #RubyOnRails
[10:11:43] jane_booty_doe: Psy-Q, like in a form?
[10:15:11] Psy-Q: jane_booty_doe: no, just generally for all client code. it's an API-only Rails app
[10:17:46] tbuehlmann: you'd probably have to use an attr_accessor like a virtual attribute for that. do you have an example?
[10:36:45] Psy-Q: it's long and a bit too complicated class, but what i want is to require a value for server_name when creating: hosting = Hosting.new(server_name: 'foo.bar.baz')
[10:36:56] Psy-Q: i can trim it down to show it
[10:42:30] Psy-Q: something like this: https://dpaste.de/fRzi
[10:43:03] Psy-Q: the server_name i want to require is a real ActiveRecord attribute, if that helps
[10:48:58] tbuehlmann: what about having a validation for server_name and early returning in your default stuff if it's not present?
[11:04:10] ariedler: has joined #RubyOnRails
[11:12:09] dionysus69: /original/inCollage_20181019_223425171.jpg I get that the first part of the name is the date, whats the last part ?
[11:13:58] dionysus69: yea I dont know
[11:14:13] dionysus69: trying to exploit one website with no permissions on activestorage files
[11:14:40] dionysus69: so theres no way to know names
[11:16:10] dionysus69: btw I am no black hat hacker so no eyebrows raised I hope ^.^
[11:41:30] jane_booty_doe2: has joined #RubyOnRails
[12:10:07] lankanmon: has joined #RubyOnRails
[12:11:14] Psy-Q: tbuehlmann: but it would still explode right after calling .new because it can't even instantiate an instance since after_initialize tries to run then, no?
[12:11:26] Psy-Q: or you mean doing that right inside after_initialize perhaps?
[12:16:32] Psy-Q: that seems to work, i'm raising ArgumentError from there now
[12:17:36] drale2k_: has joined #RubyOnRails
[12:38:24] za1b1tsu_: has joined #RubyOnRails
[12:48:29] Psy-Q: and i may be misunderstanding validates_associated. if a hosting validates_associated hosting_configuration, and hosting_configuration validates associated apache_server_aliases, shouldn't a save on hosting fail when validations on apache_server_aliases fail?
[13:07:54] drale2k_: has joined #RubyOnRails
[13:12:28] conta: has joined #RubyOnRails
[13:13:04] Psy-Q: this is weird, the hosting record is not .valid?, neither is the hosting.hosting_configuration one, but activerecord saves the hosting_one anyhow for some reason
[13:13:18] Psy-Q: and still shows hosting.hosting_configuration.valid? as false
[13:14:16] Psy-Q: oh weird, if i try to save it again it fails to save at that point. something must be wrong with the validations
[13:16:01] scrooloose: has joined #RubyOnRails
[13:16:06] za1b1tsu: has joined #RubyOnRails
[13:28:49] ss942: has joined #RubyOnRails
[13:30:55] ss942: is there something like params merge for form field?
[13:31:46] ss942: form tag*
[13:45:19] quazimodo: has joined #RubyOnRails
[13:54:45] JamieD: has joined #RubyOnRails
[14:00:00] DoubleMalt: has joined #RubyOnRails
[14:02:04] Tempesta: has joined #RubyOnRails
[14:06:13] mangold: has joined #RubyOnRails
[14:07:28] desperek: has joined #RubyOnRails
[14:08:59] DoubleMalt: has joined #RubyOnRails
[14:26:08] drale2k_: i have records with "start_time" and "end_time" fields and i want those timestamps to store the user timezone
[14:26:26] drale2k_: should i store them as UTC (default) and add the offset ?
[14:26:41] drale2k_: or should i have a separate "timezone" field on each record with the user timezone
[14:28:18] kapil____: has joined #RubyOnRails
[14:28:39] tbuehlmann: store it using UTC (which is the rails default) and convert it locally if needed
[14:30:37] apeiros_: has joined #RubyOnRails
[14:32:43] ss942: <%= form_tag(params.merge( :controller => controller_name, :action => "edit", method: :get)) do %>
[14:32:43] ss942: Why in seven hells does it render method=post?
[14:34:27] drale2k_: tbuehlmann: so just in UTC +0 ?
[14:35:25] tbuehlmann: rails will just do the right thing
[14:38:01] kanzure: has joined #RubyOnRails
[14:38:03] VSpike: has joined #RubyOnRails
[14:39:53] drale2k_: tbuehlmann: the start_time is coming from a client app running on a PC
[14:39:57] VSpike: Hi! When use the ActiveRecord pooling, is there any health-checking by the pool of the connection at any point?
[14:40:03] drale2k_: i need to preserve the timezone from that PC
[14:40:31] VSpike: If the TCP socket is disconnected, for example, will the DB connection be removed from the pool?
[14:40:36] tbuehlmann: drale2k_: when saving any time object, rails will convert it to UTC
[14:41:19] drale2k_: but how does it later know in which timezone the client PC was ?
[14:41:21] tbuehlmann: drale2k_: you have to somehow save the timezone or allow for setting it later. often times apps allow for users to setup their timezone, saving it in a user record
[14:41:25] drale2k_: i have to store that somewhere
[14:41:54] drale2k_: so would you have a separate "timezone" field or would you add an offset to the start_time timestamp itself ?
[14:43:02] tbuehlmann: if it's possible I'd store a string like 'Eastern Time (US & Canada)'
[14:43:24] drale2k_: hm right and then use a gem like tzinfo to convert
[14:45:15] tbuehlmann: or just time.in_time_zone('Berlin')
[14:46:35] quazimodo: has joined #RubyOnRails
[14:49:21] drale2k_: tbuehlmann: any idea how i can convert to a format like "Eastern Time (US & Canada)" ?
[14:49:35] drale2k_: from the PC i will get an UTC + offset
[14:50:31] tbuehlmann: never did that
[15:04:46] mangold: has joined #RubyOnRails
[15:06:00] za1b1tsu: has joined #RubyOnRails
[15:15:20] Dbugger: has joined #RubyOnRails
[15:22:59] drale2k_: has joined #RubyOnRails
[15:35:10] za1b1tsu: has joined #RubyOnRails
[15:42:46] mauro1254: has joined #RubyOnRails
[15:44:07] GodFather: has joined #RubyOnRails
[15:51:32] jsc: has joined #RubyOnRails
[15:54:16] IanMalcolm: has joined #RubyOnRails
[15:58:24] tdy: has joined #RubyOnRails
[16:09:15] Inside: has joined #RubyOnRails
[16:23:48] ss942: has left #RubyOnRails: ()
[16:23:52] conta: has joined #RubyOnRails
[16:24:10] SteenJobs: has joined #RubyOnRails
[16:26:06] apeiros: has joined #RubyOnRails
[16:34:36] chouhoulis: has joined #RubyOnRails
[16:35:11] voolik: has joined #RubyOnRails
[16:48:32] beholders_eye: has joined #RubyOnRails
[16:49:11] desperek: has joined #RubyOnRails
[16:54:56] drale2k_: can i rely on ActiveSupport::TimeZone[+1] always returning the correct thing? During daylight savings and without ?
[16:55:20] drale2k_: or would this become ActiveSupport::TimeZone[+2] during daylight savings ?
[16:56:13] conta: has joined #RubyOnRails
[17:07:14] whysthatso: has joined #RubyOnRails
[17:14:46] mices: has joined #RubyOnRails
[17:17:08] darkhanb: has joined #RubyOnRails
[17:19:11] ariedler: has joined #RubyOnRails
[17:19:12] mices: https://gist.github.com/mices/e63cab03f4f806cd21ca30c855ff6060
[17:19:31] mangold: has joined #RubyOnRails
[17:19:33] mices: trying to update all records in table ^
[17:19:52] mices: for some reason the data doesn't change
[17:21:58] Inside: model.save only saves it if the data is valid
[17:22:50] Inside: try .save! if you want to see if there an issue
[17:22:55] Inside: (because it will throw an error)
[17:23:07] mices: console shows begins and commits
[17:23:11] mices: no rollbacks
[17:23:30] Inside: also I wasn't even aware you could pass a regex to delete
[17:24:02] mices: yes try it in console on a single variable
[17:24:10] wojnar: has joined #RubyOnRails
[17:24:18] Inside: that's string::delete
[17:24:38] mices: i'll try with tr
[17:25:43] Inside: what are you trying to do with your regex?
[17:27:35] Inside: don't you want [0-9]*
[17:28:03] mices: i wanna strip all non digits from phone numbers and also remove leading +1
[17:29:49] optikalmouse: has joined #RubyOnRails
[17:31:06] Inside: In that case - I don't know
[17:32:35] Inside: my only suggestion at this point is to do:
[17:32:55] Inside: if !msg.save then <print out msg.errors >
[17:33:09] Inside: my guess is that these records are failing some other validation
[17:38:14] mices: there aren't any validations in the Sm model
[17:41:04] Inside: are you looking for delete!
[17:41:45] Inside: since delete() returns a copy, but doesn't do an in-place replace
[17:44:53] lxsameer: has joined #RubyOnRails
[17:46:01] ivanskie: has joined #RubyOnRails
[17:46:57] mices: thanks, what about the ()'s
[17:47:37] mices: but i switched it to gsub and it didn't work can you please refresh the gist
[17:47:54] Inside: you need gsub!
[17:47:56] pLaTo0n: has joined #RubyOnRails
[17:48:15] mices: ok thanks, parentheses still follow?
[17:48:40] Inside: delete! will probably work for you too
[17:49:07] mices: yea that worked thanks
[17:49:13] mices: cool insight
[17:49:48] mices: does ! mean ok to patch
[17:50:08] Inside: Any time you see a function with ! at the end, that means "this function probably modifies the data in-place"
[17:50:29] Inside: that's only a standard for the ruby standard library though
[17:51:51] Inside: rails tries to follow the same standard as well, but, for example: Model.delete! doesn't exist since Model.delete already deletes stuff for you -- irreversably
[17:52:17] Inside: and the difference between save and save! is that you can recover from "save" - save! throws an exception though
[17:54:35] mlt-: has joined #RubyOnRails
[17:56:58] mices: no need to recover from save if it doesn't save
[17:57:13] mices: ? do you mean recover like rollback?
[17:57:16] orbyt_: has joined #RubyOnRails
[17:57:27] mices: i guess i don't know what recover means
[17:57:41] mlt-: Inside: I did give minitest-bisect a try... though for whatever reason that inconsistent test is not reproducible on Linux even with same seed :(
[18:00:12] Inside: mices: https://gist.github.com/Insood/e7813071b8a8f5b18a64845fe26c1495
[18:00:29] Inside: for example you could modify the attributes of your model, then call .save to run the validations
[18:00:37] Inside: if they fail, you can check to see if they failed and show a message
[18:00:38] lxsameer: has joined #RubyOnRails
[18:00:45] Inside: if you call save! you just get an exception thrown
[18:01:15] Inside: which - is fine for stuff that can't be handled nicely (ie: rake tasks, etc) or if you really just need to abort abort abort
[18:01:23] Inside: mlt-: Aughh that sucks
[18:01:47] Inside: since you switched systems, maybe the seed changed?
[18:02:17] mlt-: Inside: yeah... I used default ruby on Debian 2.3, whereas 2.4 on Windows... gotta try rvm
[18:03:15] mlt-: Also I recalled why I disable transactional fixtures in one test... I do set serializeable isolation level for transaction in my model... so no go for transactional fixture for this one
[18:17:12] mices: this was a good learning experience for me i was looking for an old lost phone number and i found a backup of my phone's sms created by sms backup+ for android so i had to read in the text file but it was all one line so i wrote a counter to treat each 5th element as the first element in a new array
[18:18:03] mices: cause that's the way the android app creates the backup
[18:18:38] mices: the only way you know a new record is counting tabs
[18:19:09] mices: so at the end of my loop i just put counter+=5
[18:20:44] mlt-: mices: was it tab separated?
[18:21:09] roshanavand: has joined #RubyOnRails
[18:21:13] mlt-: mices: you would get by with awk
[18:21:19] mlt-: oneliner
[18:23:16] mices: gonna have to learn awk syntax i'll read a cheat sheet
[18:26:11] eddof13: has joined #RubyOnRails
[18:30:36] mostlybadfly: has joined #RubyOnRails
[18:37:34] reber: has joined #RubyOnRails
[18:43:40] eckhardt: has joined #RubyOnRails
[18:52:26] roshanavand1: has joined #RubyOnRails
[19:13:24] za1b1tsu: has joined #RubyOnRails
[19:17:01] bootstrappm: has joined #RubyOnRails
[19:19:57] ariedler: has joined #RubyOnRails
[19:22:03] VSpike: has joined #RubyOnRails
[19:27:43] fcser__: has joined #RubyOnRails
[20:06:59] eddof13: has joined #RubyOnRails
[20:11:37] levifig: has joined #RubyOnRails
[20:15:50] JamieD: has joined #RubyOnRails
[20:26:43] apeiros__: has joined #RubyOnRails
[20:36:41] weaksauce: has joined #RubyOnRails
[20:43:27] jane_booty_doe: has joined #RubyOnRails
[20:49:04] jane_booty_doe: anyone here work for instacart
[21:01:25] za1b1tsu: has joined #RubyOnRails
[21:04:01] orbyt_: has joined #RubyOnRails
[21:14:53] eddof13: has joined #RubyOnRails
[21:20:50] ariedler: has joined #RubyOnRails
[21:26:33] apeiros: has joined #RubyOnRails
[21:29:08] SteenJobs: has joined #RubyOnRails
[21:40:25] eddof13: has joined #RubyOnRails
[21:53:18] quazimodo: has joined #RubyOnRails
[21:54:28] crankharder: I want to include an association with a scope on that relationship in a query. So, say: Foo has_many :bars, and Bar has a scope :baz. I want to Foo.includes(Bar.baz) or some such so that I can Foo.includes(Bar.baz).each{|foo| foo.bars.baz} and it won't n+1. I know I can define another association on Foo that uses the scope to accomplish this. Is there a way to do this without defining that
[21:54:34] crankharder: intermediate assoc?
[21:58:56] roshanavand: has joined #RubyOnRails
[22:00:06] tycoon177: if i wanted to have a link_to and include all of the params used on the current route, is there a built in way to do this? or am i stuck manually defining all of them? the use case that i have is linking off to a pdf view of the page for printing purposes
[22:00:21] tycoon177: and to generate the pdf, i need all of the same data to be passed to the controller
[22:00:41] tycoon177: fwiw, the params that i need are all GET params
[22:01:03] crankharder: link_to foo_path(params)
[22:01:41] crankharder: (params are just params - no such thing as "GET params")
[22:03:25] tycoon177: crankharder: tyvm :)
[22:11:07] eckhardt: has joined #RubyOnRails
[22:22:48] jesfre: has joined #RubyOnRails
[22:39:15] za1b1tsu: has joined #RubyOnRails
[22:39:41] samort7: has joined #RubyOnRails
[23:02:22] Inside: crankharder: how about merge?
[23:03:03] Inside: You can do Foo.some_scope.merge(Bar.other_scope)
[23:04:19] ivanskie: has joined #RubyOnRails
[23:21:26] ariedler: has joined #RubyOnRails
[23:52:42] eddof13: has joined #RubyOnRails