« Back to channel list

#RubyOnRails - 02 July 2019

« Back 1 day Forward 1 day »
[00:06:10] mlt-: So what is the common practice with minitest fixtures? preload them? I tend to explicitly name fixtures I use in each integration test... also I have one test that cannot use transactional fixtures
[00:06:58] mlt-: I just feel like it is easy to forget to mention some necessary fixtures and in those cases tests fail only for certain seeds
[00:08:08] mlt-: If there is nothing wrong with explicit fixtures... how can I enforce them to minimize the chance that things are already in DB
[00:12:40] mlt-: got to go..will read replies if any
[00:21:47] orbyt_: has joined #RubyOnRails
[00:50:17] Ryanar: has joined #RubyOnRails
[01:21:46] crankharder: has joined #RubyOnRails
[01:24:38] Fridtjof: has joined #RubyOnRails
[01:27:32] voker57: has joined #RubyOnRails
[02:20:20] duderonomy: has joined #RubyOnRails
[02:27:51] ghormoon: has joined #RubyOnRails
[02:36:14] ariedler: has joined #RubyOnRails
[02:49:05] _aeris_: has joined #RubyOnRails
[03:03:08] orbyt_: has joined #RubyOnRails
[03:09:18] braincrash: has joined #RubyOnRails
[03:35:29] gambl0re: has joined #RubyOnRails
[03:35:53] srinidhi: has joined #RubyOnRails
[03:37:56] fcser__: has joined #RubyOnRails
[03:49:05] gambl0re: has joined #RubyOnRails
[03:49:55] srinidhi: has joined #RubyOnRails
[04:13:20] gambl0re: has joined #RubyOnRails
[04:19:15] CrackPotBob: whats the best way to test that the users current_sign_in_at column is the current time. expected: 2019-07-02 04:17:37.943346534 +0000 got: 2019-07-02 04:17:37.919219344 +0000 (compared using ==)
[04:19:23] CrackPotBob: the difference is miniscule
[04:19:38] CrackPotBob: but its enough to throw off the test
[04:19:50] CrackPotBob: can i remove the seconds from the test
[04:20:23] Norrin: yeah, test for an absolute difference instead of an exact match
[04:20:41] Norrin: exact time values like that will never match up for a unit test exactly
[04:20:41] CrackPotBob: how can i go about that
[04:21:02] Norrin: assert two conditions instead of ==
[04:21:07] Norrin: >= and <=
[04:21:10] CrackPotBob: that i agthered is due to the calling of the function for example current time in user is called first before the test
[04:22:58] CrackPotBob: ok i tried your idea but to get it accurate was a pain
[04:23:15] CrackPotBob: instead i added .to_s to both the user column and the expected column
[04:23:22] CrackPotBob: this seems to fix the issue
[04:23:46] CrackPotBob: to test i changed the factory by 1 second and sure enough i get an error
[04:24:27] Norrin: print the time in unix time instead of georgian
[04:24:41] CrackPotBob: expected: "2019-07-02 04:24:14 UTC" got: "2019-07-02 04:24:15 UTC"
[04:24:46] Norrin: then it'll be just a decimal (a number that you won't have to convert to string)
[04:25:04] CrackPotBob: i dont think itll be possible to get it anything under a second
[04:25:24] Norrin: that's fine... but how are you comparing?
[04:25:35] Norrin: there's all types of non-numeric characters in there....
[04:25:39] CrackPotBob: expect(user_object.current_sign_in_at.to_s).to eq(Time.now.utc.to_s)
[04:26:07] CrackPotBob: i do need to test with non utc times though
[04:26:24] CrackPotBob: i can forsee this becomeing an issue with different time zones
[04:26:55] CrackPotBob: although i could set a column in the db to the users time zone and then use that to set the time and to check it in the tests
[04:27:14] CrackPotBob: that could test for dynamic times but im thinking aloud
[04:27:30] Norrin: shouldn't
[04:27:39] Norrin: a users' time zone isn't static
[04:27:44] Norrin: I've seen apps do that and hated it
[04:27:49] CrackPotBob: no but i update it on the fly
[04:28:10] CrackPotBob: its done along with a seven_day_login column
[04:28:37] gb_away: has joined #RubyOnRails
[04:28:55] CrackPotBob: the app needs to be good if say a european travels to asia they can update the timezone to asia and still use the app
[04:28:58] Norrin: should just send unix time and let the local client convert to the current time zone
[04:29:56] CrackPotBob: wouldnt this become cumbersome on the app side lets say 40 countries use the app
[04:32:11] Norrin: not at all
[04:32:27] Norrin: all client should have some function that converts unix time to local time
[04:32:57] CrackPotBob: what about cloud based servers
[04:33:08] CrackPotBob: i thought those times change also
[04:33:16] CrackPotBob: due to the nature of cloud hosting
[04:33:36] CrackPotBob: or do they remain a constant and they just switch between servers leavin config the same
[04:33:50] Norrin: naw, servers need consistency. the server is going to have a time zone hard coded
[04:34:04] Norrin: otherwise logs will be impossible to parse
[04:35:48] CrackPotBob: need to check with amazon to confirm as ive got 3 servers at the minute all with different zones. but i think they just move the servers around the specified zone as like you said they need consistency.
[04:36:50] Norrin: also, a server has no reason to convert out of unix time. just leave it that way
[04:37:18] ariedler: has joined #RubyOnRails
[04:37:48] Norrin: well.... nvm... for server side rendering, use the timezone on the request object to convert to
[04:45:51] srinidhi: has joined #RubyOnRails
[04:51:56] srinidhi: has joined #RubyOnRails
[05:09:42] mikecmpbll: has joined #RubyOnRails
[05:18:46] noonipoony: has joined #RubyOnRails
[05:27:16] alxgsv: has joined #RubyOnRails
[05:31:10] conta: has joined #RubyOnRails
[05:59:33] schne1der: has joined #RubyOnRails
[06:01:41] conta: has joined #RubyOnRails
[06:05:57] sandstrom: has joined #RubyOnRails
[06:14:22] lxsameer: has joined #RubyOnRails
[06:38:02] ariedler: has joined #RubyOnRails
[06:39:00] tdy1: has joined #RubyOnRails
[07:04:26] phaul: has joined #RubyOnRails
[07:21:40] dionysus69: has joined #RubyOnRails
[07:22:19] sandstrom: has joined #RubyOnRails
[07:27:04] schne1der: has joined #RubyOnRails
[07:32:30] jefffrails35: has joined #RubyOnRails
[07:37:13] ur5us: has joined #RubyOnRails
[07:38:10] blackmesa: has joined #RubyOnRails
[07:39:42] conta: has joined #RubyOnRails
[07:44:16] deepreds1: has joined #RubyOnRails
[07:54:30] ZAJDAN: can rails do some html popup ?
[08:02:56] Ergo: has joined #RubyOnRails
[08:21:40] w0rd-driven: has joined #RubyOnRails
[08:31:20] conta: has joined #RubyOnRails
[08:38:51] ariedler: has joined #RubyOnRails
[09:10:48] deepreds1: has joined #RubyOnRails
[09:20:28] haxx0r: has joined #RubyOnRails
[09:21:17] haxx0r: this is really weired. so i have strings like "DPR5G7-69LNE-XXDNXY" which is 19 chars long. and i have a migration `t.string :reference, null: false, limit: 30` yet i get errormessage: `Mysql2::Error: Data too long for column 'reference' at row 1: `
[09:21:35] haxx0r: so i'm smart and removed the limit. just plain old ` t.string :reference, null: false, index: true
[09:21:41] haxx0r: still get the errormesage ?!
[09:21:55] srinidhi: has joined #RubyOnRails
[09:27:10] ZAJDAN: haxx0r : and when you try to change another datatype ?
[09:27:25] haxx0r: i figured out already
[09:27:36] haxx0r: it's stupid to have `belongs_to :asset` and a field called `asset`
[09:27:41] haxx0r: thought that will work ^.^
[09:27:57] haxx0r: which actually does work, but yeah, confusions
[09:31:48] ZAJDAN: in rails project is folder 'jobs'...for what it is use?
[09:33:35] haxx0r: ActiveJobs
[09:33:51] haxx0r: asynchronus executions of code, via Sidekiq most likely
[09:34:01] haxx0r: https://edgeguides.rubyonrails.org/active_job_basics.html
[09:37:32] ZAJDAN: something like database procedures?
[09:39:19] haxx0r: something like async code executions
[09:39:41] haxx0r: user signs up. sending out the email.
[09:39:50] haxx0r: but if exception in the email, user won't be saved (lol)
[09:39:53] haxx0r: https://github.com/mperham/sidekiq check that out
[09:40:25] ZAJDAN: aha...ok ok..this I probably will not need long time
[09:40:41] haxx0r: literally everybody needs it
[09:40:49] haxx0r: since ActionMailer is running async now adays
[09:40:54] haxx0r: so is ActiveStorage
[09:44:20] ZAJDAN: is some convencion where place own ruby scripts?
[09:44:40] haxx0r: ./app/lib because it's autoloaded
[09:46:03] ZAJDAN: ..../app/lib I do not have, so I have to create it
[09:46:20] haxx0r: everything in /app is autoloaded
[09:46:32] haxx0r: you can also call it /app/uselesscode
[09:46:40] haxx0r: but /app/lib is common place
[09:46:51] haxx0r: but depending on your code, there might be better places
[09:50:01] ZAJDAN: now I see I have it in : /my_application/lib .before I though you mean '/my_application/app/lib'
[09:55:23] ZAJDAN: but in my case I try call the script from /lib/folders_job ...but in browser I see it wants to go through controller: /commissions/lib/folders_job.rb"
[09:57:54] ZAJDAN: probably I should compose the script into method in my controller
[10:00:46] haxx0r: app/controllers is for everything related to the browser
[10:00:56] haxx0r: app/models for your models
[10:01:00] haxx0r: app/views self explained
[10:01:32] haxx0r: and app/lib for something like `Cronjob` or maybe `StripeAPIWrapper` or something like `BitcoinRPC`
[10:01:46] haxx0r: like code that is needed for your app, but dont belong to model
[10:03:13] ZAJDAN: I would like to use this: https://github.com/jqueryfiletree/jqueryfiletree
[10:04:10] ZAJDAN: there is also connector for Ruby.....but I have not clear if in Rails I should insert the code of the connector into my method in controller
[10:04:57] ZAJDAN: or save it as extra file in my rails project and point to this fails from jquery
[10:09:50] haxx0r: ./app/assets
[10:10:06] haxx0r: or better to say
[10:10:13] haxx0r: ./app/assets/javascripts/jquerfiletree
[10:10:20] haxx0r: and then require it from the application.js
[10:10:34] haxx0r: you really need to read about this stuff and/or watch some railscasts or other tutorials
[10:10:38] haxx0r: rails is magic
[10:12:18] ZAJDAN: the javascript itself is not problem,,,,this I have already done and use it for many other things
[10:13:08] ZAJDAN: the project which I have sent...use Jquery as mainpart and connector ....in my case RUBY script
[10:13:32] ZAJDAN: the question is how to implement the ruby script
[10:15:03] ZAJDAN: each action in Rails goes throuh controller , but the Jquery script wants to forward to ruby script...not to the controller
[10:16:10] haxx0r: so make a controller that calls the ruby script.
[10:17:08] ZAJDAN: ok...I will need to look how call script from method
[10:24:39] ZAJDAN: but I think it will not be the way I can use
[10:25:19] haxx0r: apparantly you dont know what your're doing
[10:25:53] ZAJDAN: in Rails not...In PHP I have same project completely done
[10:26:08] haxx0r: we don't care about PHP since Ruby and Rails are superior
[10:26:39] ZAJDAN: ok...I will ask You from other side
[10:26:57] ZAJDAN: all rails action must goes through controller?
[10:27:41] ZAJDAN: my experiences are that yes
[10:31:26] ZAJDAN: I think when in JS is via AJAX callen some external file I shoud forward it in Rails via routes..or not?
[10:34:38] ZAJDAN: https://dpaste.de/0n5o ...the option 'script' says where get the information
[10:35:06] ZAJDAN: but maybe insted of the file I could forward it to method via URL
[10:53:46] ZAJDAN: ok....in the JS I use URL instead of path and seems to be it will be for what Iam looking
[10:55:08] ariedler: has joined #RubyOnRails
[11:03:15] lankanmon: has joined #RubyOnRails
[11:06:10] blackbaba: has joined #RubyOnRails
[11:07:17] conta: has joined #RubyOnRails
[11:07:51] ZAJDAN: could somebody clarify why the variable 'dir' is empty? https://dpaste.de/2pfX
[11:08:47] GodFather: has joined #RubyOnRails
[11:12:56] crankharder: has joined #RubyOnRails
[11:18:06] deathwishdave: has joined #RubyOnRails
[11:33:18] haxx0r: nobody can help you with that littel bit of code
[11:42:11] ZAJDAN: haxx0r: ....here is method https://dpaste.de/dAiB ... here is Jquery from where I call the method: https://dpaste.de/9HYB
[11:43:28] haxx0r: is that a rails controller?
[11:43:53] ZAJDAN: yes...method in controller
[11:45:11] ZAJDAN: seems to be Jquery send the parameters correctly ...from server log I see: Processing by CommissionsController#folders as HTML Parameters: {"dir"=>"/6_BUGGY/", "onlyFolders"=>"false", "onlyFiles"=>"false", "multiSelect"=>"false"}
[11:47:41] ZAJDAN: puts dir ...returns []
[11:48:10] haxx0r: if this is your controller, i don't even want to help you
[11:48:13] haxx0r: this is not a rails controller
[11:48:18] haxx0r: a rails controller would be something like
[11:48:56] haxx0r: def folders; folder = JqueryFolder.run(params[:directory}); render json: folder: end
[11:52:07] ZAJDAN: ah ok.....in that way I will not need the ruby script.....do I understand correctly?
[11:53:06] haxx0r: i dont understand your problem nor does anybody else in this channel
[11:53:13] haxx0r: you need to learn basics of ruby and ruby controllers
[11:53:19] haxx0r: i wont reply you anymore. sorry mate
[11:53:45] ZAJDAN: no problem....
[11:55:56] GodFather: has joined #RubyOnRails
[12:02:40] ZAJDAN: actually the sense of the FileTree is, that Jquery(Ajax) sends string which means 'name of directory' ...and server side has predefined path where should find the 'sub'directory from the query and browse the content...send it back as html <li> to Ajax
[12:03:11] ZAJDAN: thats all
[12:04:11] conta: has joined #RubyOnRails
[12:13:56] crankharder: has joined #RubyOnRails
[12:35:15] haxx0r: has joined #RubyOnRails
[12:35:50] HorizonShadow: has joined #RubyOnRails
[12:51:34] crankharder: has joined #RubyOnRails
[13:01:41] AlHafoudh: has joined #RubyOnRails
[13:11:04] GodFather: has joined #RubyOnRails
[13:28:02] Terens: has joined #RubyOnRails
[13:28:18] Terens: should i use integer or numeric for storing money?
[13:29:24] haxx0r: you need to youse DECIMAL
[13:29:40] haxx0r: t.decimal :amount, precision: 20, scale: 8
[13:29:46] haxx0r: (for cryptocurrency)
[13:29:58] haxx0r: also, if you deal with money, checkout `gem money`
[13:30:04] HorizonShadow: Please don't store monetary values as a float
[13:30:05] haxx0r: it does allf or you
[13:30:10] haxx0r: and/or `money-rails`
[13:52:10] srinidhi: has joined #RubyOnRails
[13:56:47] GodFather: has joined #RubyOnRails
[13:57:03] alxgsv1: has joined #RubyOnRails
[13:57:36] schne1der: has joined #RubyOnRails
[13:59:45] HorizonShadow: has joined #RubyOnRails
[14:06:15] alxgsv: has joined #RubyOnRails
[14:25:38] AlHafoudh: does anyone have idea if it is possible for puma to reserve some threads for healthchecks?
[14:25:41] Saukk: has joined #RubyOnRails
[14:27:42] za1b1tsu: has joined #RubyOnRails
[14:32:56] Terens: @haxx0r, yes decimal but senior dev claimed that integer is the only type that is safe
[14:33:19] haxx0r: dafuq why?
[14:33:21] Terens: and from his previous experience very big apps used int
[14:33:29] haxx0r: good luck using integer with crypot
[14:33:45] haxx0r: show me how to store 1_000_000_000.12345678 DOGE Coin
[14:33:45] Terens: it is not for this purpose
[14:36:23] Terens: He says I know that there are tons of examples with integers
[14:37:05] brool: has joined #RubyOnRails
[14:40:12] haxx0r: yeah, he's also quite stupid for saying integer is the only solution
[14:40:20] haxx0r: if you're making a shop and have 2 digit prices: ok.
[14:40:33] haxx0r: if you go for financial application, do not do integer
[14:44:18] conta: has joined #RubyOnRails
[14:51:15] Dr_MDMA_MD: has joined #RubyOnRails
[15:13:49] duderonomy: has joined #RubyOnRails
[15:14:34] duderonomy: has joined #RubyOnRails
[15:15:23] duderonomy: has joined #RubyOnRails
[15:15:31] emptyflask: has joined #RubyOnRails
[15:16:15] duderonomy: has joined #RubyOnRails
[15:16:59] duderonomy: has joined #RubyOnRails
[15:19:16] deepreds1: has joined #RubyOnRails
[15:21:09] za1b1tsu_: has joined #RubyOnRails
[15:25:05] orbyt_: has joined #RubyOnRails
[15:28:44] Technodrome: has joined #RubyOnRails
[15:37:05] deepreds1: has joined #RubyOnRails
[15:37:23] al-damiri: has joined #RubyOnRails
[15:48:26] HorizonShadow: has joined #RubyOnRails
[15:56:34] haxx0r: any chance to throw a `Proc` into `validates_numericality_of` so that the value we check against is depending on an association?
[15:59:59] Xiti: has joined #RubyOnRails
[16:02:26] gambl0re: has joined #RubyOnRails
[16:09:07] duderonomy: has joined #RubyOnRails
[16:15:38] G: has joined #RubyOnRails
[16:26:07] AlHafoudh: has joined #RubyOnRails
[16:34:03] Technodrome: has joined #RubyOnRails
[16:44:03] haxx0r: to my own answer: yes it's working `validates_numericality_of :amount, less_than: :minimum_amount` given a symbol will be executed correctly
[16:57:16] schne1der: has joined #RubyOnRails
[16:58:36] duderonomy: has joined #RubyOnRails
[17:26:22] srinidhi: has joined #RubyOnRails
[17:26:59] jefffrails35: has joined #RubyOnRails
[17:29:55] uks: has joined #RubyOnRails
[17:47:02] xco: has joined #RubyOnRails
[18:07:13] kurko_: has joined #RubyOnRails
[18:08:06] conta: has joined #RubyOnRails
[18:15:59] sandstrom: has joined #RubyOnRails
[18:20:45] AlHafoudh: has joined #RubyOnRails
[18:29:44] Slogger: With active storage how do you rename a file (set the filename column's value) as part of its upload?
[19:06:17] orbyt_: has joined #RubyOnRails
[19:12:18] gambl0re: has joined #RubyOnRails
[20:22:03] codefriar: has joined #RubyOnRails
[20:22:58] codefriar: I'm coming back to a rails project after a long time away. I used to know how to pass data to a new_object_path without it being visible in the url params, but I seem to have forgotten. Can anyone school me?
[20:29:18] xco: has joined #RubyOnRails
[20:32:54] quazimodo: has joined #RubyOnRails
[20:40:28] ellcs: has joined #RubyOnRails
[20:41:44] gambl0re: has joined #RubyOnRails
[20:43:44] Technodrome: has joined #RubyOnRails
[20:47:58] orbyt_: has joined #RubyOnRails
[21:09:00] codefriar: has left #RubyOnRails: ("Textual IRC Client: www.textualapp.com")
[21:18:18] ur5us: has joined #RubyOnRails
[21:27:03] Dr_MDMA_MD: has joined #RubyOnRails
[21:33:08] Dbugger: has joined #RubyOnRails
[21:46:51] emptyfl4sk: has joined #RubyOnRails
[21:50:17] gambl0re: has joined #RubyOnRails
[21:55:05] quazimodo: has joined #RubyOnRails
[22:06:29] jarr0dsz: has joined #RubyOnRails
[22:06:40] jarr0dsz: hello everyone is it possible to rollback a rails console command?
[22:06:52] jarr0dsz: i made a mistake and could not find how to roll it back, is it possible at all?
[22:07:55] orbyt_: has joined #RubyOnRails
[22:08:54] havenwood: jarr0dsz: If you start the console with the `--sandbox` flag, it'll rollback db modifications on exit.
[22:09:06] jarr0dsz: i know my goal was to modify records but i made a mistake
[22:09:12] jarr0dsz: so i launced it with non sandbox.
[22:09:29] jarr0dsz: i can manually correct but if there is a undo command it would save time
[22:10:06] havenwood: There isn't an undo command.
[22:10:27] jarr0dsz: ah, wouldent that be a nice feature for rails to have? then i have to manually correct :(
[22:10:48] havenwood: How would Rails know what to undo? I don't know how I'd start to implement that feature.
[22:10:56] xco: has joined #RubyOnRails
[22:11:08] jefffrails35: has joined #RubyOnRails
[22:12:06] jarr0dsz: just save the last recordset and reverse it with a undo command in console
[22:12:17] jarr0dsz: like rake db:rollback mechanism
[22:12:55] havenwood: What does "just save the last recordset" mean?
[22:14:11] havenwood: jarr0dsz: If you were using a DB like Datomic, it'd make sense to be able to just roll back. The SQL servers that Rails supports out of the box don't have a concept of history. DB schemas are a different thing.
[22:15:01] havenwood: jarr0dsz: If you were using a gem like Paper Trail or Audited, you'd have the ability to roll back.
[22:16:29] havenwood: jarr0dsz: When you think about db migrations, they're ordered, saved to your disk, and rolling back means just not applying the last.
[22:16:30] NeXTSUN: has joined #RubyOnRails
[22:16:45] jarr0dsz: ok i understand
[22:17:13] havenwood: Or undoing the last, rather, which sometimes can be done automatically and sometimes you have to define yourself.
[22:18:15] havenwood: jarr0dsz: I like having facts, where your data has history. SQL was born in an age of very little memory, and that wasn't a luxury it could afford.
[22:20:01] havenwood: Rich Hickey is a proponent of "facts": https://channel9.msdn.com/posts/Rich-Hickey-The-Database-as-a-Value
[22:20:56] havenwood: Around the 24 minute mark.
[22:22:05] havenwood: "It's not an eternal thing that Sally likes pizza."
[22:22:19] havenwood: I'm not sure disliking pizza is a great example! :P
[22:25:08] AlHafoudh: has joined #RubyOnRails
[22:55:04] usmanity: has joined #RubyOnRails
[22:56:56] renegadeandy: has joined #RubyOnRails
[22:56:59] Dr_MDMA_MD: has joined #RubyOnRails
[22:57:21] renegadeandy: Hi all! Is there any good tutorials or guides on how i may integrate image classification (perhaps I can train a model) into a rails app?
[23:06:15] Ryanar: has joined #RubyOnRails
[23:08:16] AlHafoudh: has joined #RubyOnRails
[23:16:56] NeXTSUN: has joined #RubyOnRails
[23:28:20] gambl0r3: has joined #RubyOnRails
[23:35:30] emptyfl4sk: has joined #RubyOnRails