« Back to channel list

#RubyOnRails - 19 December 2017

« Back 1 day Forward 1 day »
[00:02:17] jrabe: has joined #RubyOnRails
[00:08:27] orbyt_: has joined #RubyOnRails
[00:10:14] mtkd: has joined #RubyOnRails
[00:16:53] romeoh: has joined #RubyOnRails
[00:19:58] ramfjord: has joined #RubyOnRails
[00:36:19] cagomez: has joined #RubyOnRails
[00:36:35] cagomez: has joined #RubyOnRails
[00:40:24] sevenseacat: has joined #RubyOnRails
[00:52:10] orbyt_: has joined #RubyOnRails
[00:58:49] creature: has joined #RubyOnRails
[01:03:48] xibalba: has joined #RubyOnRails
[01:13:05] alfiemax: has joined #RubyOnRails
[01:15:23] dblessing: has joined #RubyOnRails
[01:17:39] romeoh: has joined #RubyOnRails
[01:20:23] cagomez: has joined #RubyOnRails
[01:33:34] mtkd: has joined #RubyOnRails
[02:02:12] cagomez: has joined #RubyOnRails
[02:08:21] alfiemax: has joined #RubyOnRails
[02:18:25] romeoh: has joined #RubyOnRails
[02:20:37] kapil___: has joined #RubyOnRails
[02:49:09] ramfjord: has joined #RubyOnRails
[02:50:21] cagomez: has joined #RubyOnRails
[02:51:41] tamouse__: has left #RubyOnRails: (""Poets have been mysteriously silent on the subject of cheese" -- G.K.Chesterson")
[02:51:52] meesles: has joined #RubyOnRails
[02:55:02] ebsen: has joined #RubyOnRails
[02:58:24] alfie: has joined #RubyOnRails
[03:09:33] alfiemax: has joined #RubyOnRails
[03:10:19] JusticeFries: has joined #RubyOnRails
[03:19:12] romeoh: has joined #RubyOnRails
[03:20:07] Dimik: has joined #RubyOnRails
[03:37:46] orbyt_: has joined #RubyOnRails
[03:38:24] mtkd: has joined #RubyOnRails
[03:39:06] ebsen: has joined #RubyOnRails
[03:50:21] workmad3: has joined #RubyOnRails
[03:56:54] romeoh: has joined #RubyOnRails
[04:24:58] slash_nick: has joined #RubyOnRails
[04:30:57] nso95: has joined #RubyOnRails
[04:42:48] ramfjord: has joined #RubyOnRails
[04:49:58] dmiller85: has joined #RubyOnRails
[05:05:52] Vashy: I want to create a scaffold for the details of a game. Something like: `rails g scaffold MatchDetails`
[05:06:13] Vashy: Is the pluralness of MatchDetails going to mess things up?
[05:06:16] Vashy: I'm a rails beginner
[05:07:35] dmiller85: I'd help if I knew :)
[05:12:52] baweaver: It's smart enough to figure out what you mean Vashy
[05:13:18] Vashy: just saw there's a --force-plural flag
[05:23:14] drale2k_: has joined #RubyOnRails
[05:24:16] alfiemax: has joined #RubyOnRails
[05:26:19] iamarun: has joined #RubyOnRails
[05:33:14] srinidhi: has joined #RubyOnRails
[06:17:08] reber: has joined #RubyOnRails
[06:20:49] za1b1tsu: has joined #RubyOnRails
[06:21:33] za1b1tsu: Can someone tell me why is the validation of numericality is needed here? https://gist.github.com/bbtdev/868ff9f93671d98dbf1dc897c2eb803c
[06:26:42] sevenseacat: so people dont try to charge things like 'an arm and a leg'
[06:28:07] za1b1tsu: sevenseacat: I ask because I need this validation for a string and a integer (xor)? And it says for the xor method to work validation of numericality is needed.
[06:28:24] za1b1tsu: and I dont see how the type would affect the xor method
[06:29:02] sevenseacat: it doesnt, given you're xoring booleans
[06:31:53] za1b1tsu: sevenseacat: do I need to test types in general? Doesn't the ActiveModel or db take care of that for us?
[06:32:10] za1b1tsu: I never seen validations regarding types
[06:32:19] sevenseacat: try it and see what happens
[06:34:07] sevenseacat: i see and write validations like that all the time
[06:41:30] _aeris_: has joined #RubyOnRails
[06:43:02] Radar: "charge_xor_payment" is named after what the method does exactly...
[06:43:07] ramfjord: has joined #RubyOnRails
[06:43:13] Radar: I would call it "charge_or_payment_provided"
[06:43:52] Radar: and maybe there's an easier way of doing this: a transaction could be an amount and if it's negative then it's a charge, but if it's positive it's a payment?
[06:44:01] Radar: Then you wouldn't need this validation at all.
[06:46:29] drale2k_: has joined #RubyOnRails
[06:51:22] dionysus69: has joined #RubyOnRails
[07:01:10] ur5us: has joined #RubyOnRails
[07:04:57] drale2k_: has joined #RubyOnRails
[07:05:13] apeiros: has joined #RubyOnRails
[07:09:23] KeyJoo: has joined #RubyOnRails
[07:17:23] pwnd_nsfw: has joined #RubyOnRails
[07:23:49] yottanami: has joined #RubyOnRails
[07:25:14] yottanami: I am trying to deploy project on prodution it seems precompile works currectly project can load css file but I got 404 during load js file
[07:28:59] pwnd_nsfw: yottanami, how are you loading the js file? Is it one from your assets folder?
[07:29:33] pwnd_nsfw: know that the file names are changed when you compile them
[07:32:39] apeiros: has joined #RubyOnRails
[07:43:33] mtkd: has joined #RubyOnRails
[07:44:18] lupine: has joined #RubyOnRails
[07:46:53] yottanami: pwnd_nsfw, actually I have problem in loading uglified version of application.js
[07:47:37] yottanami: ..../assets/application-5d2cc9b6ed0970834c28f80c6e2449c7f4b225372d4832c8f64fb2331252f53b.js 404 (Not Found)
[07:49:15] alfie: has joined #RubyOnRails
[07:50:02] blackmesa: has joined #RubyOnRails
[07:50:33] pwnd_nsfw: yottanami, can I get a link to your production link?
[07:51:53] yottanami: pwnd_nsfw, Unfortunately it is on a private network but I can share a file if it helps
[07:52:36] pwnd_nsfw: Can you share the html between your <head> tags?
[07:52:44] pwnd_nsfw: And the code that produces it?
[07:52:58] yottanami: pwnd_nsfw, Here are assets and env files http://dpaste.com/2MWXK0X http://dpaste.com/3BX1DNE
[07:53:33] yottanami: pwnd_nsfw, It is <%= javascript_include_tag 'application' %>
[07:55:41] pwnd_nsfw: With limited information, I can't debug much
[08:10:32] apeiros: has joined #RubyOnRails
[08:24:47] Jameser: has joined #RubyOnRails
[08:31:16] pikislabis: has joined #RubyOnRails
[08:32:38] AzaToth: has joined #RubyOnRails
[08:34:07] defsdoor: has joined #RubyOnRails
[08:35:19] morfin60: has joined #RubyOnRails
[08:35:27] Dimik: has joined #RubyOnRails
[08:38:05] ur5us: has joined #RubyOnRails
[08:38:35] lunarkitty7: has joined #RubyOnRails
[08:39:05] swati_27: has joined #RubyOnRails
[08:39:22] swati_27: Hi. Need help with rails server
[08:39:37] swati_27: Getting an error when I try to run it
[08:39:53] swati_27: https://www.irccloud.com/pastebin/dl4ZKeto/
[08:41:36] morfin60: how non-activerecord should look like?
[08:41:45] morfin60: with same conventions etc
[08:42:00] sevenseacat: swati_27: did you do what it says?
[08:42:12] swati_27: yes. It's stuck
[08:42:35] swati_27: I ran "gem install bundler" and nothing happens for long
[08:42:58] sevenseacat: thats not what it says to do
[08:43:15] ramfjord: has joined #RubyOnRails
[08:43:50] swati_27: I ran "bundle install" in my project too
[08:43:59] swati_27: but it's terminated with an error
[08:44:01] morfin60: i remember i had one somewhere(only naming conventions, validations and something else were used)
[08:44:17] morfin60: but it was not "persistable"
[08:45:02] swati_27: https://www.irccloud.com/pastebin/7qLKsJgN/
[08:45:21] swati_27: https://www.irccloud.com/pastebin/Gb7doG7K/
[08:45:35] swati_27: https://www.irccloud.com/pastebin/M2pi0bQx/
[08:45:51] swati_27: https://www.irccloud.com/pastebin/HkWLWBHx/
[08:46:05] swati_27: https://www.irccloud.com/pastebin/eMmeuuPV/
[08:47:10] morfin60: you should install development packages
[08:47:41] swati_27: Could you please tell me?
[08:47:43] morfin60: i mean using brew/apt-get install/yum/pacman/something else
[08:54:26] mikecmpbll: has joined #RubyOnRails
[09:06:46] yottanami: I am using docker and the wired that css loads completed in production but can not find js manifest file
[09:14:14] blackmesa1: has joined #RubyOnRails
[09:21:49] yottanami: error in log file is here
[09:22:03] yottanami: F, [2017-12-19T09:21:19.207636 #1] FATAL -- : [8bf8e6ce-e0c6-40cc-b79b-de495fec5834] ActionController::RoutingError (No route matches [GET] "/assets/application-5d2cc9b6ed0970834c28f80c6e2449c7f4b225372d4832c8f64fb2331252f53b.js"):
[09:30:36] arBmind: has joined #RubyOnRails
[09:34:00] swati_27: morfin60: It helped. Thank you so much. 😄
[09:34:06] blackmesa1: has joined #RubyOnRails
[09:48:40] mtkd: has joined #RubyOnRails
[10:02:33] ur5us: has joined #RubyOnRails
[10:06:50] Cavallari: has joined #RubyOnRails
[10:19:40] dminuoso: yottanami: Look into the docker container. What do you see in your assets folder?
[10:22:13] NL3limin4t0r: has joined #RubyOnRails
[10:23:44] pikislabis: has joined #RubyOnRails
[10:30:30] yottanami: dminuoso, It creates a volume and it seams file exists in directory even css can works without any problem
[10:33:35] dminuoso: yottanami: The error suggests that rails is catching the request.
[10:33:49] dminuoso: yottanami: Do you intend for your rails application to serve the asset? Or do you intend nginx to handle it?
[10:33:54] yottanami: dminuoso, maybe file is not generating
[10:34:13] blackmesa1: has joined #RubyOnRails
[10:34:27] yottanami: dminuoso, Here are assets and env files http://dpaste.com/2MWXK0X http://dpaste.com/3BX1DNE
[10:34:51] dminuoso: yottanami: Please answer my question. =)
[10:36:08] yottanami: dminuoso, I use nginx to handle it and here is the config http://dpaste.com/3WAPY6C
[10:36:24] dminuoso: yottanami: Then there's something messed up in your nginx configuration.
[10:36:41] yottanami: dminuoso, but how it load css content?
[10:36:45] dminuoso: yottanami: The error message means that nginx forwarded the request to the rails application (which is not configured to serve static assets, so it doesn't know what to do with the request)
[10:36:52] dminuoso: yottanami: I don't know, but it's not a rails problem.
[10:37:39] yottanami: dminuoso, I think the js file is not generated
[10:38:03] dminuoso: yottanami: You do not seem to understand what Im saying if that is your conclusion.
[10:38:14] dminuoso: yottanami: The fact that Rails is getting the request means nginx is not doing its job.
[10:39:18] dminuoso: yottanami: If the file was not there, then worst case the browser would get a 404 from the webserver.
[10:39:33] marr: has joined #RubyOnRails
[10:40:24] dminuoso: So for now this is just an nginx configuration issue.
[10:41:35] dminuoso: yottanami: I _think_ the try_files might not end up finding it, causing the behavior.
[10:42:08] dminuoso: yottanami: So again, check your docker container and _look_ into the assets folder. Check if the file is there.
[10:43:28] ramfjord: has joined #RubyOnRails
[10:44:10] yottanami: dminuoso, I was wrong the file is not there and it was the oldest version file
[10:44:21] yottanami: I mean older docker images
[10:46:57] dminuoso: yottanami: If you rebuild the container from scratch, is the application.js still missing?
[10:49:05] yottanami: dminuoso, Yes, I tried to rebuild and precompile, logs shows it is working on js files but I can not find the .js file with the hash that browser is trying to find
[10:50:09] s2013: has joined #RubyOnRails
[10:52:03] dustinm`: has joined #RubyOnRails
[11:05:26] arBmind: has joined #RubyOnRails
[11:11:39] cschneid_: has joined #RubyOnRails
[11:22:22] ldnunes: has joined #RubyOnRails
[11:40:25] jrabe: has left #RubyOnRails: ("Rejoining channels")
[11:55:23] Ergo: has joined #RubyOnRails
[12:00:57] cheeti: has joined #RubyOnRails
[12:01:15] uks: has joined #RubyOnRails
[12:02:09] cheeti: hi, i am using pdfkit to generate dynamic pdf but i am not able to add index page. how to add index page?
[12:03:25] atrius: has joined #RubyOnRails
[12:03:27] ur5us: has joined #RubyOnRails
[12:11:25] dminuoso: yottanami: Do you see any js file?
[12:16:29] mostlybadfly: has joined #RubyOnRails
[12:18:24] yottanami: dminuoso, I removed the assets volume from docker and now it works correctly
[12:18:42] yottanami: dminuoso, But it save assets inside docker
[12:19:02] sameerynho: has joined #RubyOnRails
[12:23:29] fschuindt: has joined #RubyOnRails
[12:44:28] pikislabis: has joined #RubyOnRails
[12:49:59] Tempesta: has joined #RubyOnRails
[12:50:43] tcopeland: has joined #RubyOnRails
[12:52:38] DrYockel: has joined #RubyOnRails
[12:54:45] one_zero: has joined #RubyOnRails
[13:01:21] _ritchie_: has joined #RubyOnRails
[13:10:13] desperek: has joined #RubyOnRails
[13:12:53] _aeris_: has joined #RubyOnRails
[13:16:40] Jameser: has joined #RubyOnRails
[13:21:50] cagomez: has joined #RubyOnRails
[13:29:16] KeyJoo: has joined #RubyOnRails
[13:42:05] jordansz: has joined #RubyOnRails
[13:42:22] jordansz: hello everyone, does anyone know how I could write the contents of a customlogger not to a file but to a database?
[13:42:31] jordansz: i cannot find anything on this online so far or i did not search for the right terms
[13:43:15] jordansz: so from this: https://gist.github.com/anonymous/bb3d8626568a6a3457eff584c389cd11 to a database storage i try
[13:48:15] jlebrech: has joined #RubyOnRails
[13:48:52] jordansz: nobody knows it seems imposible not documented, and not sure how i could add my custom code its seems to not working makeing only 1 entry in db
[13:48:53] jlebrech: i'm getting Net::ReadTimeout: Net::ReadTimeout for route /admin/config.php using a rails as api
[13:49:17] Aherin: has joined #RubyOnRails
[13:51:26] jlebrech: ActionController::RoutingError: No route matches [GET] "/admin/config.php" annoying script poking my app
[13:56:52] Cavallari: has joined #RubyOnRails
[13:57:21] jlebrech: can you block direct access to an app via it's ip rather than using the domain?
[14:02:38] Takumo: Hi all, I'm using the acts_as_nested_set gem, and need a way to find or create a record based on the ancestry in the set
[14:02:57] Takumo: i.e. if I have 'Foo/Bar/Baz' I want to find or create Baz, Bar and Foo in the tree
[14:03:09] JusticeFries: has joined #RubyOnRails
[14:03:48] ur5us: has joined #RubyOnRails
[14:04:48] Takumo: Is there a method to do this?
[14:05:41] marahin: jlebrech you could just make your webserver ignore all routes ending with *.php when it comes to that
[14:05:49] swati_27: has joined #RubyOnRails
[14:05:49] marahin: but that has nothing to do w/ Rails
[14:11:38] jlebrech: marahin: ok cheers
[14:13:43] borodin: has joined #RubyOnRails
[14:32:00] arBmind: has joined #RubyOnRails
[14:36:25] za1b1tsu: has joined #RubyOnRails
[14:37:45] za1b1tsu: Hello, I'm using rspec for testing. I'm testing an object that is dependent on the creation of other 2 objects. My codes get really messy, what would be the best practice for this? How should I declare the 2 objects first for all the test
[14:38:24] za1b1tsu: I also need to access them in the test and for the creation of the object I'm testing
[14:40:34] krawchyk: has joined #RubyOnRails
[14:41:55] JusticeFries: has joined #RubyOnRails
[14:44:05] waseem_: has joined #RubyOnRails
[14:45:04] KeyJoo: has joined #RubyOnRails
[14:46:39] ramfjord: has joined #RubyOnRails
[14:51:03] romeoh: has joined #RubyOnRails
[14:52:11] krawchyk: has joined #RubyOnRails
[14:58:52] sameerynho: has joined #RubyOnRails
[15:12:39] safetypin: has joined #RubyOnRails
[15:20:34] morfin60: how can i make rails autoload models from other gem?
[15:23:40] dmiller85: has joined #RubyOnRails
[15:27:21] troys: has joined #RubyOnRails
[15:28:18] krawchyk: has joined #RubyOnRails
[15:32:35] mikecmpb_: has joined #RubyOnRails
[15:33:04] krawchyk: has joined #RubyOnRails
[15:34:24] _ritchie_: has joined #RubyOnRails
[15:40:50] nogic: has joined #RubyOnRails
[15:44:03] JusticeFries: has left #RubyOnRails: ("Textual IRC Client: www.textualapp.com")
[15:46:05] marr: has joined #RubyOnRails
[15:53:22] mikecmpbll: has joined #RubyOnRails
[15:57:48] borodin: has joined #RubyOnRails
[16:04:26] ur5us: has joined #RubyOnRails
[16:06:45] _ritchie_: has joined #RubyOnRails
[16:14:06] ramfjord: has joined #RubyOnRails
[16:14:26] Saukk: has joined #RubyOnRails
[16:15:17] Cavallari: has joined #RubyOnRails
[16:21:06] SteenJobs: has joined #RubyOnRails
[16:26:00] mtkd: has joined #RubyOnRails
[16:44:40] cagomez: has joined #RubyOnRails
[16:54:56] jottr: has joined #RubyOnRails
[16:55:38] dblessing: has joined #RubyOnRails
[16:56:54] FrostCandy: has joined #RubyOnRails
[16:57:05] mtkd: has joined #RubyOnRails
[16:57:24] krawchyk: has joined #RubyOnRails
[16:57:48] MurphyOne: has joined #RubyOnRails
[16:59:47] FrostCandy: I have a line like User.find_by_email(email), where does ruby look to figure out where to find the User model? Do I need to require or include any files to make it look for User?
[17:02:07] swati_27: Hi. Is there a way to change your default DB from sqlite to mysql ?
[17:02:28] swati_27: database.yml file shows sqlite3 as default.
[17:03:02] mikecmpb_: has joined #RubyOnRails
[17:08:02] mtkd: has joined #RubyOnRails
[17:09:04] pLaTo0n: has joined #RubyOnRails
[17:19:39] ramfjord: has joined #RubyOnRails
[17:23:03] borodin: has joined #RubyOnRails
[17:32:24] kapil___: has joined #RubyOnRails
[17:32:28] [Butch]: has joined #RubyOnRails
[17:34:17] waseem_: swati_27: Just change the adapter to mysql2 and other relevant settings. Also add mysql2 gem to your Gemfile. It should work.
[17:34:39] meesles: has joined #RubyOnRails
[17:35:04] jtperreault: swati_27: pass the flag for the DB you want when using the rails new command. rails new myapp -d mysql
[17:35:36] swati_27: @waseem_ the "Gemfile" in main folder?
[17:35:59] waseem_: swati_27: Yes.
[17:36:22] swati_27: @jtperreault I'l try this too.
[17:36:35] swati_27: @jtperreault seems easier
[17:37:03] waseem_: swati_27: This should get you a working application: https://stackoverflow.com/a/5872284/100466
[17:37:34] swati_27: @waseem_ thank you so much :)
[17:39:01] waseem_: FrostCandy: User is a Ruby constant, Rails uses a naming convetion to map it to users table in your database.
[17:41:56] dviola: has joined #RubyOnRails
[17:42:32] dminuoso: FrostCandy: http://guides.rubyonrails.org/active_record_basics.html#naming-conventions
[17:47:22] one_zero: has joined #RubyOnRails
[17:47:52] krawchyk: has joined #RubyOnRails
[17:59:04] FrostCandy: dminuoso: oh ok thanks
[17:59:12] hahuang65: has joined #RubyOnRails
[17:59:15] orbyt_: has joined #RubyOnRails
[18:01:40] mtkd: has joined #RubyOnRails
[18:01:56] Cache_Money: has joined #RubyOnRails
[18:02:09] cagomez: if Foo has_many Bar, with dependent: destroy, and inverse_of Foo, does Bar also have the dependent: destroy option set?
[18:02:45] ur5us: has joined #RubyOnRails
[18:03:28] amperry: has joined #RubyOnRails
[18:03:49] amperry: hey folks, gotta question: using Warden's login_as() method with capybara only mock logs you in as someone for the very next request, but I need to login and do a variety of things to test. Someone (dminuoso, I think) recommended using rspec's shared_context, but does that log you in before every request? Wouldn't you lose access to the params hash that way, if so?
[18:07:18] krawchyk: has joined #RubyOnRails
[18:07:38] dminuoso: amperry: No it just logs you in once, but that's all you need.
[18:10:53] amperry: dminuoso: does it always do that, or just when in a shared context? Because I was pointed to this when I thought my first login_as test failed: https://github.com/hassox/warden/blob/master/lib/warden/test/helpers.rb#L19-L21
[18:11:12] dminuoso: amperry: shared context has nothing to do with warden.
[18:11:29] Exhiled: has joined #RubyOnRails
[18:11:30] dminuoso: think of a shared context as a module in the ruby sense that you can just include to share common "things"
[18:15:09] dminuoso: amperry: https://gist.github.com/dminuoso/5d2649f84f4a07e8d2b1bd208da729ab
[18:15:18] dminuoso: this is a sample from our specs
[18:15:24] amperry: dminuoso: okay. That's what I'd originally thought, but I was running into problems and was pointed to that page, which seems to state that the login_as() call is good for the next request only.
[18:15:39] dminuoso: amperry: Yes but you only need one request.
[18:15:56] dminuoso: amperry: Capybara maintains the login session.
[18:16:43] amperry: Isn't virtually every page a request, or am I misusing the term?
[18:17:06] amperry: I mean, I'm glad it does things the way that makes sense to me.
[18:17:14] amperry: I'm just confused by how it's stated there.
[18:17:50] dminuoso: amperry: How do you think a login session works?
[18:18:35] dminuoso: amperry: Let's demystify how this works.
[18:18:42] dminuoso: amperry: Using my example
[18:19:11] dminuoso: amperry: https://gist.github.com/dminuoso/5d2649f84f4a07e8d2b1bd208da729ab#file-foo-rb-L9 this ensures that before each test login_as(user, scope: :user) is called
[18:19:22] dminuoso: amperry: That calls https://github.com/hassox/warden/blob/master/lib/warden/test/helpers.rb#L19-L21
[18:19:34] dminuoso: Which calls https://github.com/hassox/warden/blob/master/lib/warden/proxy.rb#L170
[18:19:48] dminuoso: amperry: Now just give the brief comment above a read.
[18:20:03] dminuoso: set_user basically magically makes a user appear and feed it into the session.
[18:20:12] dminuoso: what does "the session" mean?
[18:21:34] dminuoso: When you log into a regular rails website using standard settings, rails will prepare some information about the "logged in user", encrypt it, and feed it to rack.
[18:21:43] amperry: a set of stored data used while someone is either logged in or otherwise recognized by a site, before they time out or are otherwise perceived to have left.
[18:21:48] dminuoso: On the response, rack will add a HTTP header Set-Cookie, which includes that encrypted cookie.
[18:21:58] dminuoso: The next time rails interacts, that cookie will be send back.
[18:22:01] dminuoso: And that cookie is the session.
[18:22:28] dminuoso: The browser will maintain that session for some duration, lets just assume infinitely for now,
[18:23:03] dminuoso: so the next time rails makes a request, that cookie is sent along
[18:23:23] dminuoso: and warden basically sees it, and fixates the user on whatever is specified in there.
[18:23:57] dminuoso: so you only have to "login once", because after that the "logged in state" has been established in the session which the browser maintains.
[18:24:03] dminuoso: this is no different.
[18:24:43] dminuoso: all login_as does, is kind of bolt a hook ontop, that when the next request is made, it kind of fakes as if there was another visit/post shenanigans before hand, such that the cookie will be set in the response of that "next request"
[18:25:17] romeoh: has joined #RubyOnRails
[18:25:35] amperry: dminuoso: cool, I was just having trouble staying logged in for a test, but it seems to have shaken out now. (Where "shaken out" means gone away after I've edited the file, but I don't know why.)
[18:25:40] dminuoso: it doesn't "authenticate the next request", it just provides that hook to "inject the user into the session object" into the next request.
[18:25:54] dminuoso: if that makes sense
[18:26:00] amperry: perfect sense
[18:26:10] ramfjord: has joined #RubyOnRails
[18:27:23] dminuoso: amperry: You could also provide a before hook that manually handled that flow, it would just be a bit slower. :)
[18:34:44] rwb-averon: has joined #RubyOnRails
[18:35:40] rwb-averon: Rails 4.1.7 - I see we can concurrently add indices. Is it possible to concurrently remove indices?
[18:36:09] rwb-averon: remove_index(:notifications, [:object_id, :object_type, :read], {:algorithm=>:concurrently})
[18:36:12] rwb-averon: rake aborted!
[18:36:14] rwb-averon: StandardError: An error has occurred, all later migrations canceled:
[18:36:17] rwb-averon: wrong number of arguments (given 3, expected 1..2)
[18:41:39] dminuoso: amperry: https://gist.github.com/dminuoso/235f3dd62f64a1fac1c55402ec334faf
[18:41:58] mikecmpbll: has joined #RubyOnRails
[18:42:10] dminuoso: rwb-averon: do you have the need to support multiple rdbms?
[18:42:22] rwb-averon: answer: remove_index :notifications, column: [:object_id, :object_type, :read], algorithm: :concurrently
[18:42:29] rwb-averon: only postgres
[18:42:41] rwb-averon: I think I got it
[18:42:48] dminuoso: rwb-averon: You have to do this outside a transaction then.
[18:42:50] alfiemax: has joined #RubyOnRails
[18:42:55] rwb-averon: got into a weird state b/c you have to disable transaction
[18:43:01] rwb-averon: yeah totally
[18:43:04] dminuoso: rwb-averon: Yes.
[18:43:23] amperry: dminuoso: groovy
[18:43:25] dminuoso: rwb-averon: Also note that if you only have to support postgres, you probably should try and write them in raw postgres.
[18:43:28] rwb-averon: the syntax for adding/removing isn't symmetrical
[18:43:38] dminuoso: This gives you more flexibility rather than just "trying to make AR happy for no good reason"
[18:43:50] dminuoso: (even migrations allow you to execute arbitrary sql)
[18:44:01] rwb-averon: gotcha, thank you dminuoso
[18:45:10] dminuoso: amperry: and updated because of 2 mistakes.
[19:04:10] dmiller85: has joined #RubyOnRails
[19:06:57] ur5us: has joined #RubyOnRails
[19:07:46] mtkd: has joined #RubyOnRails
[19:11:18] Dimik: has joined #RubyOnRails
[19:11:42] dmiller85: hello everyone
[19:19:40] havenwood: dmiller85: hi
[19:22:09] peterhil: has joined #RubyOnRails
[19:25:44] rwb-averon: has joined #RubyOnRails
[19:26:45] apeiros: has joined #RubyOnRails
[19:27:14] borodin: has joined #RubyOnRails
[19:30:10] borodin: has joined #RubyOnRails
[19:35:24] romeoh: has joined #RubyOnRails
[19:42:11] jnollette: has joined #RubyOnRails
[20:00:08] jottr: has joined #RubyOnRails
[20:08:24] gauravgoyal: has joined #RubyOnRails
[20:10:48] orbyt_: has joined #RubyOnRails
[20:11:43] alfiemax: has joined #RubyOnRails
[20:17:04] _ritchie_: has joined #RubyOnRails
[20:21:03] gauravgoyal: has joined #RubyOnRails
[20:26:27] desperek: has joined #RubyOnRails
[20:29:47] jottr: has joined #RubyOnRails
[20:33:14] paulywill: has joined #RubyOnRails
[20:40:41] my123: has joined #RubyOnRails
[20:41:39] cagomez: has joined #RubyOnRails
[20:45:22] jottr: has joined #RubyOnRails
[20:50:38] amperry: having trouble with a Pundit policy_scope when showing a new record, gist here: https://gist.github.com/amp108/767bcb14c171c6412aeb003535ff96f5
[20:52:19] amperry: on a side note, anyone know how to get gist to display records in the order you added them, rather than alphabetically?
[20:57:20] cagomez: has joined #RubyOnRails
[21:11:38] unreal: has joined #RubyOnRails
[21:12:32] cagomez: has joined #RubyOnRails
[21:16:42] fox_mulder_cp: amperry: hm. you can pass options like ?sort='num' and filter databy it
[21:18:48] amperry: fox_mulder_cp: is this in lieu of using Pundit.policy_scope()?
[21:20:24] fox_mulder_cp: if you wait for some mins, i create example code from my existant code
[21:20:39] amperry: sure, thanks
[21:23:34] amperry: oh, I think I might know something about my code that could be doing it
[21:23:41] Radar: GOOD MORNING
[21:23:50] amperry: but I'd need to know how to mock that in a factory
[21:24:38] amperry: Radar: GOOD MORNING ± TIME ZONE OFFSET
[21:25:26] fox_mulder_cp: amperry: my dev server currently in reboot after os upgrade, so i wait it too )
[21:26:29] amperry: fox_mulder_cp: I've figured it out. It's an aspect of my code that I wasn't accounting for when I created a User in a test factory.
[21:26:37] quazimodo: has joined #RubyOnRails
[21:27:17] amperry: user has_one :current_prop, class: Property, but also has_many :properties
[21:27:49] Radar: amperry: my guess is that you're not calling "authorize @traffic, :show?" in the show / edit / update actions and that's why it's not calling the show? method in your policy.
[21:28:12] cagomez: has joined #RubyOnRails
[21:28:38] amperry: Radar: I haven't had to call authorize for anything else, which is why it would surprise me if I had to do it here.
[21:29:09] amperry: but I think it's a matter of how I mocked up a user in my factory, which I will check straightaway and let you know.
[21:29:19] Radar: amperry: I'm only going off what I see in the code for Rails 4 in Action: https://github.com/rubysherpas/r4ia_examples/blob/master/ticketee/app/controllers/tickets_controller.rb#L43
[21:29:26] Radar: It's been a while since I've used Pundit.
[21:29:47] Radar: Also: I am using policy_scope like this: https://github.com/rubysherpas/r4ia_examples/blob/master/ticketee/app/controllers/projects_controller.rb#L5
[21:30:03] Radar: and I guess that's made possible by https://github.com/rubysherpas/r4ia_examples/blob/master/ticketee/app/policies/application_policy.rb#L37-L39
[21:30:17] Radar: Maybe Pundit's changed since the time we wrote that book.
[21:31:23] fox_mulder_cp: amperry: my line is : @item = policy_scope(ZonePrice).find(params[:id])
[21:31:26] amperry: it's also possible my code is very, very wrong, but it appears to work the way I call it.
[21:31:36] fox_mulder_cp: for your sort question
[21:32:06] amperry: fox_mulder_cp: the sort question was about gist.github.com, not about my app :P
[21:33:16] fox_mulder_cp: amperry: ahaha )
[21:35:09] amperry: it's just that I upload the files there in an order that makes some kind of narrative/explanatory sense, but then the alphabetization throws that out of whack.
[21:37:02] amperry: and without unsightly hacks like za_things_controller.rb and zb_other_things_controller.rb, I don't know how to override it. Might message someone on that site.
[21:42:29] cagomez: has joined #RubyOnRails
[21:44:14] cagomez: has joined #RubyOnRails
[21:50:41] CJKinni: has joined #RubyOnRails
[21:52:01] orbyt_: has joined #RubyOnRails
[22:09:29] _ritchie_: has joined #RubyOnRails
[22:21:03] quazimodo: has joined #RubyOnRails
[22:25:38] amperry: updated my question on gist. It boils down to, how to add an association in a factory, given a 'has_many... through' relationship? Gist: https://gist.github.com/amp108/767bcb14c171c6412aeb003535ff96f5
[22:32:05] sameerynho: has joined #RubyOnRails
[22:33:33] Jon30: has joined #RubyOnRails
[22:34:30] Jon30: help guys, in capistrano, how do i specify an scm path? set :scm_command, "...." is not working for me. It's still calling /env git
[22:48:13] arBmind: has joined #RubyOnRails
[22:49:21] ebsen: has joined #RubyOnRails
[22:49:26] Disavowed: has joined #RubyOnRails
[22:57:33] Disavowed: Hey all. Dumb question but I'm really stuck: why does this generate a GET? <%= link_to 'butts', upvote_deal_path(deal), method: :put %>
[22:57:48] Disavowed: I want a PUT request, but it's almost as if it's not picking up the options hash
[23:00:30] amperry: Disavowed: just a guess, but is javascript disabled?
[23:00:50] amperry: has joined #RubyOnRails
[23:01:03] amperry: cursed network
[23:04:50] Disavowed: amperry: thank you so much for the quick response! Doesn't seem to be that because stuff between the <script> tags gets executed
[23:05:14] Disavowed: I'm banging my head against a wall! It works fine as a GET if I update the route, but PUT is what I really want
[23:05:23] Radar: Disavowed: no JS errors in your console?
[23:06:00] Disavowed: Well, 'navigated to http://127.0.0.1:3000'
[23:06:14] Radar: Rightio. Not a clue then.
[23:06:26] Disavowed: no worries, thank you for weighing in!
[23:06:38] Radar: Here's one from an example app that I have lying around: <%= link_to "Archive User", [:archive, :admin, @user], method: :patch,
[23:06:43] Radar: So tbqh you're doing it right
[23:06:54] Radar: Disavowed: what's your layout file look like?
[23:07:33] s2013: has joined #RubyOnRails
[23:09:43] Disavowed: Radar: I've tried it with brackets and {} and all sorts of variants - I wonder if I've screwed up the JS somehow.
[23:09:46] Disavowed: Radar: And sorry to sound dumb, but when you say layout, do you mean layouts/application.html.erb or something else?
[23:09:58] Disavowed: (just starting a new project to see if I can replicate it)
[23:14:13] Radar: Disavowed: yeah application.html.erb
[23:14:29] Radar: Can you gist it? I'm thinking like you might be missing the rails_ujs thingamajig that adds this in
[23:16:31] Disavowed: Radar: Sure! https://pastebin.com/1U9pbTRk
[23:16:45] Disavowed: Looks like you're right. I don't remember deleting it =/
[23:17:04] Radar: !whypbsucks
[23:17:04] helpa: Pastebin sucks because it loads slowly, has ads which are distracting and has terrible formatting. Please use Gist (http://gist.github.com) instead.
[23:17:20] Disavowed: Oh sorry, I'll repaste.
[23:17:21] Radar: Disavowed: Ok, so you're including application.js which is good, now what's in that file?
[23:17:38] Disavowed: Radar: oh my god that's what it is. I've removed a bunch of stuff from that!
[23:18:16] Radar: https://gist.github.com/radar/7c6d05d6b4e066a448f0f9a6ca5fc316
[23:18:26] Radar: Here's what it should look like. Line 13 is the one you're probably missing.
[23:19:33] Disavowed: Pshhhhhhhhhhhhhhhhh
[23:19:36] Disavowed: Thank you so much!
[23:19:39] Disavowed: I'm such an idiot
[23:19:41] Radar: all good :) Easy mistake to make.
[23:19:44] Disavowed: that's an hour I'll never get back!
[23:19:54] Disavowed: It is? I should have just left it instead of interfering with it!
[23:19:59] _ritchie_: has joined #RubyOnRails
[23:20:09] Disavowed: Thank you so much, and I'm so impressed that you lot were able to figure that out from such little information
[23:20:20] Disavowed: Well that's one I'll never forget.
[23:21:11] Radar: It's easy if you know what to look for. Either JS is disabled or that file wasn't loaded. GET request was the clue. rails-ujs will make the request a PUT instead of a GET through its magic
[23:24:36] Disavowed: I'm still impressed :P Thank you again, so so much. You don't have any recommendations for Rails books do you? I feel like I can be productive but don't know enough of the internals
[23:24:47] Disavowed: (but I love it too much to ever touch Django again)
[23:24:52] helpa: Rails 4 in Action - http://manning.com/bigg2 - An excellent book combining Rails and TDD/BDD development. Written by Rebecca Skinner, Steve Klabnik, Ryan Bigg, Yehuda Katz
[23:24:57] Radar: Here's one I prepared earlier.
[23:25:20] Disavowed: I feel like I'm hitting a lot of the questions that get asked a lot. I'll lurk more, I promise!
[23:25:23] Disavowed: Thank you so much for that
[23:25:34] Radar: No worries mate :)
[23:36:18] amperry: If a lease has_many monthly_charges, and a monthly_charge belongs_to a cp_code, then, given a lease with one monthly_charge, and that monthly_charge's cp_codes_id is an existing id, shouldn't I be able to call lease.monthly_charges.first.cp_code ?
[23:36:46] amperry: although maybe that belongs_to should be a has_one
[23:44:13] tfitts: belongs to should be fine and that should work.
[23:44:50] tfitts: does cp_code have_many monthly_charges?
[23:45:02] tfitts: not sure if it matters for the direction your going though.
[23:47:39] amperry: tfitts: nope, cp_code doesn't have_much of anything
[23:47:55] amperry: I sit corrected
[23:48:17] tfitts: is that not working? what error are you getting?
[23:49:08] amperry: lease.monthly_charges.first.cp_codes_id = 31 (which is 'RENT', fwiw), but lease.monthly_charges.first.cp_code is nil.
[23:50:03] tcopeland: has joined #RubyOnRails
[23:50:14] tfitts: do you have a method that overrides cp_code or something?
[23:50:49] tfitts: does CpCode.find(31) work?
[23:51:01] tfitts: is it cp_codes_id or cp_code_id?
[23:53:04] tjbp: has joined #RubyOnRails
[23:53:52] amperry: CpCode.find(31) works.
[23:54:12] amperry: it is cp_codes_id, but perhaps it shouldn't be
[23:55:13] fugee: has joined #RubyOnRails
[23:55:27] mices: how do i dropship with spree
[23:56:21] mices: the gem only works with rails below 4.3
[23:56:27] mices: should i go with that?
[23:56:52] mices: also the gem works with an older version of spree
[23:57:42] tfitts: amperry: definitely should be singular
[23:58:22] tfitts: you can override cp_code and have it do def cp_code CpCode.find_by_id(cp_codes_id) end
[23:58:37] tfitts: but that won't give you eager loading and joins as a correctly named column would.
[23:58:52] tfitts: I think you can also setup a different foreign key on the CpCode model if you need to
[23:58:56] tfitts: not sure if this is an existing or new app.
[23:59:01] tfitts: if it's new just rename the column.