#RubyOnRails - 04 May 2017
« Back 1 day Forward 1 day »
[00:20:18] ravster: I'm looking for an alternative to devise for user-authentication. I would like something that works with the rails-views as well as an api. Does anyone have suggestions for me to check out?
[00:53:40] mostlybadfly: hey all, does anyone have experience with the RSpotify gem? I'm attempting to check for a 200 response code prior to rendering a view. Any suggestions for how to accomplish this? Issue is that if a user deauthorizes Spotify on my app, it will cause issues in one of my views unless I do a check prior.
[00:54:03] mostlybadfly: or I guess conversely check for a 401 error prior to completing further actions
[01:20:16] andrew9184: is there a way to fix deep munge? ie empty arrays stay as arrays instead of being nil
[02:28:54] petrol_gas: Can someone point me to migration column types in the API Docs? I found the following link to add_column. The doc refers to native types, but not where they're defined. I want to read the options for each of the native types.
[02:29:02] petrol_gas: The link: http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-add_column
[02:58:34] maddman: hi there! I'm with problems to install rails on windows 10. Someone can help me?
[02:59:56] fryguy: maddman: you aren't going to like this answer, but you'll be much better served by running rails on another operating system
[03:00:25] helpa: http://gist.github.com - Put your codes online with pretty syntax highlighting and the ability to embed it into other pages.
[03:07:30] maddman: sevenseacat, fryguy, https://gist.github.com/ramoel/d9997160644424171c2627edf2e0b4cb
[03:09:28] sevenseacat: https://github.com/rubygems/rubygems/issues/1540 as silly as it sounds... rebooting seems to fix it?
[04:01:07] dminuoso: sevenseacat: Reading the related SO posts, it's one of those big reasons why cygwin sucks quite a bunch.
[06:14:36] morfin: If i restart puma with pumactl it does not daemonize process unless i use daemonize true in config/puma.rb is that right thing?
[10:18:34] soahccc: Hey guys, is there an easy way to alter the response if basic auth goes 401? I tried http://stackoverflow.com/a/7640418/1806803 but I still get the 401 response: https://gist.github.com/2called-chaos/69c6a7d43033d8a2e8ed12f136df3b29
[10:45:39] Kilo`byte: hai there, with the postgresql adapter, can i somehow execute raw prepared/parametrized statements
[12:29:11] jlebrech: I have a angular 1.x frontend and want to put it in my backend rails 5.1 app. does rails 5.1 also work with angular 1.x as it does with 2
[13:08:01] Criten: I want to discus a possible proxy through the rails app to access the compiled packs
[13:09:35] jlebrech: i want to use rails to let old angular and new angular live side by side without going though a full upgrade
[13:24:41] jlebrech: Criten: i don't even want to trust angular if the upgrade path sucks so much. 2-4 upgrade seems better. but with rails 5.1 we could write the js in anything :)
[13:27:30] mustmodify: Angular 2's breakage is what gave me the opportunity to try out React. So I thought overall it was good for me. :)
[13:30:49] jlebrech: i just don't understand why i need to written cargo cult bootstraping magic to write an app. everything i write should be about my app and the rest should be managed by the framework.
[13:31:43] jlebrech: the cargo cult wrote a lot of nice stuff for me to piggyback off, but now everyone has seen the light
[13:33:19] jlebrech: yeah, like dependency injection, providers, nginject, $scope, writting directives. 1 was very odd.
[14:32:04] mrbubbles: hey folks, I'm trying to debug a spree checkout. I'm getting an error about $(...).validate is not a function but I've checked and I can see that the script is included in the page
[14:32:44] mrbubbles: I've also compared this install (which is modified) to a clean spree install and the scripts match so I'm not sure what's going on. Could it be down to the asset pipeline?
[15:00:30] vedu: ravster: I did hack it already. But I want to set it to nil on update, based on a related radio button. So once it gets a value, I cannot set it to nil
[15:02:48] mrbubbles: Ah - it looks like jQuery is being loaded twice, once by the app and then once by spree. Hmmm
[15:31:55] bennyzr: Hi, can anyone help me with monkey patching a form helper gem? I tried creating middleware to add the patch and am getting an "A copy of [middleware] has been removed from the module tree but is still active" error.
[16:23:22] greengriminal: Hey, does anyone have any thoughts on why this migration maybe failing: https://gist.github.com/davidpatters0n/b2a5c778bff82ab5d057fb7cace8873f I'm using postgres. Also have looked at similar questions on SO and they don't seem related.
[16:50:54] pwnd_nsfw: "#identifier" is used for serveral things nowadays, but originally it was an anchor like mustmodify describes
[16:57:46] mustmodify: I assume it isn't configured in config/routes.rb because Rails won't get information after a #, IIRC.
[16:59:23] mustmodify: Orxata_: At this point, I suspect you're in the "I don't know enough to know what I don't know" camp. It's a hard place to be. Stay in the struggle. You'll get there.
[17:20:59] sunya7a: hello all. Could someone help me with the following query: https://gist.github.com/anonymous/24d3ef0be8f41d0d6aff7a7bbc951190
[17:21:20] sunya7a: I'm wondering if there's a way to combine loading the user: :profile instead of calling it twice
[17:29:39] bennyzr: Hi, what's the best way to add a method to an existing module in a gem using a patch?
[18:04:49] nir0: hi guys, i've got a method can?(permission) in application_controller, helper_method on it. now i cannot stub it from view spec
[18:07:16] nir0: if i try to stub it, it goes with errors, like i'm missing some gem. any solution, like view.stub() just throws undefined method stub
[18:09:07] nir0: view.stub(:can?).and_return(:false) throws undefined method `stub' for #<#<Class:0...>
[18:28:52] bryanculver: I'm wondering if there is a better way than brute forcing this search: I'm looking for clubs that people have in common through their list of memberships
[18:30:15] bryanculver: Is there a better way than grabbing all clubs for all users then filtering through each to determine if it contains all users?
[18:31:27] nir0: bryanculver: you could use some sql to make it faster, depends on what particulary you want to achieve
[18:32:09] bryanculver: I can think of one "short cut" as I'm trying to really just tell if it's boolean (in common or not) of grabbing the first users groups, then stepping though each user and "narrowing" down the list until no groups in common or no users left to check
[18:33:41] bryanculver: I'm just wondering if a) RoR has a AR helper for this (don't want to reinvent the wheel) or if a SQL query will be markedly faster.
[18:45:42] ravster: bryanculver: I'm not sure what you want to achieve. Can you walk us through an example?
[18:46:24] bryanculver: Ok so I have a Chat and I want to determine if all members are in the same club or if they are from different clubs
[18:46:57] bryanculver: Any user can be a part of any number of clubs and any club can have an arbitrary number of members, always changing on both
[18:47:48] bryanculver: I using this "filter" to determine of this chat is exclusive to the club or if someone has invited someone from outside of the club
[18:47:52] ravster: So you want two different lists of users? Or if the user is looking at a list of users, they will see a marker if another user has at least one club in common?
[18:49:20] bryanculver: I've done a mock test with recursive programming and it executed in 10 microseconds. This however doesn't short circuit when no match potentials are left
[18:50:34] bryanculver: (example User A in clubs [1,2,3] User B in clubs [4,5,6] User C in clubs [2,4])
[18:52:44] bryanculver: My current recursive algorithm doesn't short circuit, of which I could switch to (example the first arrangement would not check user C since already we know it's not exclusive)
[18:53:14] ravster: I'm thinking something like 2 queries. The first query would search the users, sorted by the number of clubs they belong to (ascending order), and pick the first user. So you have the least number of club_ids to check.
[18:53:22] bryanculver: My overarching question was whether or not I was reinventing the wheel of any pre-exisitng ActiveRecord helper
[18:55:36] ravster: The second query would look at all users in the Chat where they have a club_id for each club_id in the list, and see if any of the queries has a count equal to the number of users in the Chat.
[18:56:56] ravster: I'm pretty sure that all that can be brought down into a single SQL query, though.
[18:58:09] bryanculver: I've done stuff like that before but I get a bit... ill-stomached about custom queries. More points of debugging / security issue IMHO
[18:58:46] bryanculver: However if the SQL query is 1000X more performant, then I would change my mind.
[18:59:22] bryanculver: I can't see any chat with more than 10 members at any time and no more than 3 active club memberships at a time per person
[18:59:33] ravster: I think it really boils down to what you think the smallest club-membership-count would be for each Chat
[19:00:15] ravster: The SQL uber-query would be very cool, but I doubt that people need to figure things out that quickly
[19:01:11] bryanculver: Yeah, I've had to do similar with networking equipment and available VLANS across 20+ network devices.
[19:02:54] bryanculver: Hmmm... I probably could put a grab bag together for a post. Gotta dust off the ol' pencil for that lol
[19:11:56] Eindoofus: do methods such as belongs_to, has_many, etc. do anything other than provide info about the class when working with a mongo database?
[20:14:01] daveomcd: when I do "bundle update gem_name" on my development machine... when I run capistrano how does production know to update only that gem for itself? Is it because of the gem lock file recording the version number?
[20:38:20] amperry: hey folks, I've got a utility ruby script that tries to connect to my database with the same auth tokens as rails, but I'm getting an error: 'FATAL: password authentication failed for user "rayles" (PG::ConnectionBad)'. I can also get into the psql client using those same credentials. Anyone run into a similar problem before?
[20:42:29] amperry: mlt-: tried that; was getting a different error before, then put "host: 'localhost'" in the script
[20:44:17] mlt-: amperry: any chance this user has ~/.pgpass or whatever DB you are using with another password? I'm not sure about precedence though.
[20:45:05] amperry: mlt-: turns out the default password was overriding the one I wanted to use; I fixed it :P
[20:54:50] mlt-: So it looks like I can't use #update_all AR method with nested attributes:( Kind of expected though...
[20:55:01] amperry: no, somewhere else. I'm running a set of utility scripts to import data from a completely different data source. The pain is hard to describe :S
[21:29:31] mlt-: Do I have to supply id value for a nested attribute while updating? I'm getting DB constraint violation as apparently AR doesn't figure out what I want... I thought it would just take it from parent, but from what I see it takes that from parent to look up only, and then tries to set null
[21:32:13] mlt-: Shall I use hidden field on a form? Sounds ugly... not quite my case, but I feel like it will work http://stackoverflow.com/q/9944065/673826
[21:36:03] mlt-: Answers like this http://stackoverflow.com/a/18985990/673826 suggest that id for nested stuff is expected in params
[21:36:46] mlt-: I use f.simple_fields_for and it doesn't look like it places id for nested stuff :(
[21:48:06] linetrace: stack level too deep errors with mutually associated models, each having validates_associated
[21:49:00] linetrace: what's best practice on validates_associated to prevent recursive validations? on the has_one or the has_many or just pick?
[21:49:43] linetrace: (in my case, one has to exist before the other, so maybe only validates_associated on the one that has to be created second (since the prior had to be valid to save)?
[22:08:59] Slogger: Is there an accepted best practice for stripping wrapping whitespace of model attributes? Or is it mostly just do whatever?
[22:32:37] helpa: linetrace: Clearly explain what is happening and create a Gist (http://gist.github.com), (formatted neatly please: http://bit.ly/1q75oia) of the code that is causing the problem you are encountering, as well as any useful output like stacktraces.
[22:36:43] Slogger: Things like user names, would prefer not to have things like "bob " and "bob" happen. I'm not actually having a problem, this is more so there seem to be many ways of accomplishing it, so I was mostly curious if the community has a typical methodology since there seems to be everything from multiple gems to simple before_save and before_validation calls.
[22:42:48] Slogger: (I'm also a little curious because in several JS projects/libs/frameworks I've used similar things seem to be done on assignment/on set, as opposed to on save.)
[23:21:44] carlosd: In a view file, when I call something like = render 'my_partial', some_var: 'some_value' do link_to 'some_link', some_path end