« Back to channel list

#RubyOnRails - 02 January 2018

« Back 1 day Forward 1 day »
[00:08:15] cschneid_: has joined #RubyOnRails
[00:08:54] j0llyr0tten: Radar: where is the code for the database adapters?
[00:09:17] Radar: J0llyr0tten: depends. Why?
[00:09:22] j0llyr0tten: Say if I wanted to create a new back-end.
[00:09:29] Radar: J0llyr0tten: For which database?
[00:09:42] j0llyr0tten: Actually a triplestore.
[00:10:14] j0llyr0tten: I'm trying to gauge how insane the idea is.
[00:10:49] Radar: J0llyr0tten: ActiveRecord is fine for RDBMSes but if you're not using one... then it'd probably be easier to use a different gem to speak to it
[00:10:52] Radar: Which triplestore?
[00:11:44] j0llyr0tten: My idea is to go through Ruby-RDF and so be able to use any triplestore it can talk to.
[00:12:39] kapil___: hello . i have slug column in every model. I want that each slug model's validation write in one place. i don't knw design patterns how to do it?
[00:12:41] t0adst00l: has joined #RubyOnRails
[00:14:37] alfiemax: has joined #RubyOnRails
[00:17:30] j0llyr0tten: kapil___: you want to share validation between models?
[00:18:09] j0llyr0tten: this is just a guess but you could inherit all models that have a slug column from the same super class
[00:18:31] j0llyr0tten: and put the method in the super class, that might work
[00:18:46] kapil___: J0llyr0tten: thanks
[00:19:08] Radar: kapil___: Any particular reason not to use a library that implements slugging behaviour already, like friendly_id?
[00:19:26] kapil___: Radar: using friendly_id
[00:20:07] kapil___: Radar: sorry, not using it
[00:20:35] kapil___: Radar: because it causing problems
[00:22:00] kapil___: Radar: I want to save special caracters to save in slug like . (DOT)
[00:22:30] cschneid_: has joined #RubyOnRails
[00:23:44] kapil___: Radar: also +(Plus)
[00:28:25] j0llyr0tten: kapil___: what's a slug?
[00:28:55] kapil___: its a code / sort name
[00:29:12] kapil___: i am not using rest api.
[00:31:01] kapil___: friendly_id. looking good. will integrate it again.
[00:32:13] kapil___: J0llyr0tten: is there any other method to share validations between models?
[00:32:56] one_zero: has joined #RubyOnRails
[00:37:54] ResidentBiscuit: has joined #RubyOnRails
[00:40:03] zwliew: has joined #RubyOnRails
[00:43:35] ResidentBiscuit: has joined #RubyOnRails
[00:44:24] walidvb: has joined #RubyOnRails
[00:44:29] walidvb: happy new year everyone
[00:56:29] cschneid_: has joined #RubyOnRails
[01:01:23] j0llyr0tten: kapil___: i do not know
[01:04:30] alfiemax: has joined #RubyOnRails
[01:11:40] garyserj: has joined #RubyOnRails
[01:12:05] garyserj: Does linux/bsd/macos give any error message when doing db:reset? like a permissions issue
[01:13:17] garyserj: i'm wondering if anybody has any insight on https://github.com/rails/rails/issues/31589
[01:37:50] alfiemax: has joined #RubyOnRails
[01:38:43] cschneid_: has joined #RubyOnRails
[01:39:46] ResidentBiscuit: has joined #RubyOnRails
[01:40:19] darkhanb: has joined #RubyOnRails
[01:45:41] mtkd: has joined #RubyOnRails
[01:49:56] dustinm`: has joined #RubyOnRails
[02:02:13] Exuma: has joined #RubyOnRails
[02:12:31] Cache_Money: has joined #RubyOnRails
[02:18:57] cschneid_: has joined #RubyOnRails
[02:27:40] Cache_Money: has joined #RubyOnRails
[02:40:20] alfiemax: has joined #RubyOnRails
[02:44:12] Exuma: has joined #RubyOnRails
[02:55:18] cschneid_: has joined #RubyOnRails
[03:27:33] alfiemax: has joined #RubyOnRails
[03:33:41] ResidentBiscuit: has joined #RubyOnRails
[03:40:58] cschneid_: has joined #RubyOnRails
[03:50:44] mtkd: has joined #RubyOnRails
[04:22:10] cschneid_: has joined #RubyOnRails
[04:59:27] Exuma: has joined #RubyOnRails
[05:10:50] iamarun: has joined #RubyOnRails
[05:20:36] Alchemical: has joined #RubyOnRails
[05:41:08] ur5us: has joined #RubyOnRails
[05:48:41] cschneid_: has joined #RubyOnRails
[05:49:20] baweaver: kapil___: stay on stable versions of Rails for now.
[05:55:04] mtkd: has joined #RubyOnRails
[06:02:16] KeyJoo: has joined #RubyOnRails
[06:08:41] jrp93: has joined #RubyOnRails
[06:17:52] DmitryBochkarev: has joined #RubyOnRails
[06:46:28] AnotherOne: has joined #RubyOnRails
[06:47:45] darkhanb: has joined #RubyOnRails
[06:56:51] cschneid_: has joined #RubyOnRails
[06:59:18] wethu: has joined #RubyOnRails
[07:00:54] t0adst00l: has joined #RubyOnRails
[07:07:42] wethu: has joined #RubyOnRails
[07:26:56] TinkerTyper: has joined #RubyOnRails
[07:29:33] one_zero: has joined #RubyOnRails
[07:40:40] conta: has joined #RubyOnRails
[07:59:13] mtkd: has joined #RubyOnRails
[08:00:44] hive-mind: has joined #RubyOnRails
[08:04:26] cschneid_: has joined #RubyOnRails
[08:14:04] gambl0re: has joined #RubyOnRails
[08:29:04] kiffpowerss: has joined #RubyOnRails
[08:29:15] kiffpowerss: Hey guys. Anybody online right now that could help me ?
[08:31:45] tbuehlmann: Kiffpowerss: possible. what's the question?
[08:32:34] kiffpowerss: I have multiple models with has many relations. I want to merge these objects. When I do that the scopes dont work on the merged list but on the original list until I save the model to the database. What would be the best way to implement this.
[08:34:08] kiffpowerss: Hope my question was clear
[08:56:33] kiffpowerss: I got a model user which has many of the model balance. I want to merge multiple user and combine the balances of these users. But the scopes I have on the balance model dont work until I save the new model to the database.
[08:56:49] dionysus69: has joined #RubyOnRails
[08:57:55] dionysus69: has joined #RubyOnRails
[09:01:06] AnotherOne: i'm assuming you create a new user, then its clear there can be no scopes because the object does not actually exist in the database and so no relation can be created
[09:01:24] AnotherOne: meaning you have to save the new user first
[09:01:29] AnotherOne: and then can create the relations
[09:02:00] AnotherOne: and then its straight forward
[09:05:18] mikecmpbll: has joined #RubyOnRails
[09:09:01] dminuoso: Kiffpowerss: You can merge relations with ActiveRecord::SpawnMethods#merge
[09:09:15] dminuoso: See http://api.rubyonrails.org/classes/ActiveRecord/SpawnMethods.html
[09:11:22] t0adst00l: has joined #RubyOnRails
[09:13:15] ur5us: has joined #RubyOnRails
[09:15:07] kiffpowerss: anotherone: I am duplicating the first model and its associations and then merging the other 2 users to it.
[09:16:20] kiffpowerss: dminuoso: I am also merging fields from the user model. The end result will have the earliest startdate en the last enddate. But does the merge save it to the database ? Because I dont know if thats best practice or not. Because right now I am mering them, saving it to the database, and then deleting it after i am done with the model
[09:16:49] AnotherOne: just iterate over the first model
[09:17:40] arBmind: has joined #RubyOnRails
[09:17:47] AnotherOne: may not be the best performance but you are only doing it once
[09:18:46] kiffpowerss: anotherone: Thats what I am doing right now. Combining the end results, reading the data from this merged object after I saved it to the database and then deleting the model after I am done with it.
[09:19:16] AnotherOne: and whats your concern?
[09:19:54] dminuoso: Kiffpowerss: I do not understand your question.
[09:19:58] helpa: 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.
[09:20:32] marr: has joined #RubyOnRails
[09:21:41] kiffpowerss: anotherone: If there was a better way of doing this.
[09:22:16] AnotherOne: possible but why waste time with it you are not doing this so often maybe only once
[09:22:42] kiffpowerss: Cool thanks. Will go with thsi for now. Will keep looking for alternatives
[09:23:08] AnotherOne: ok but do not waste your time on that only if performance gets an issue
[09:23:17] hd1: has joined #RubyOnRails
[09:29:09] kiffpowers: has joined #RubyOnRails
[09:33:13] hd1: my rspec tests fail with " If you are seeing this on one of your tests, ensure that your tests are either executing the Rails middleware stack or that your tests are using the `Devise::Test::ControllerHelpers` module to inject the `request.env['warden']` object for you.", adding 'import Devise::Test::ControllerHelpers' to my test doesn't fix the
[09:33:13] hd1: problem, claiming I need to define a setup method, defining a blank setup method with no args, makes it whinge that it needs 2 and adding the 2 arguments doesn't help.... any suggestions?
[09:37:40] dminuoso: hd1: Gist your spec as well as your rails_helper.rb and spec_helper.rb
[09:40:58] hd1: 999https://gist.github.com/hdiwan/29a8d165d294cb1f03db55bff6731a99
[09:41:22] hd1: https://gist.github.com/hdiwan/29a8d165d294cb1f03db55bff6731a99
[09:41:39] hd1: apologies, must have hit '9' a few times by mistake
[09:42:18] dminuoso: hd1: Can you edit the gist and also include the full output of rspec `your_spec --backtrace` ?
[09:42:53] dminuoso: that is, `rspec your_spec --backtrace`
[09:44:09] hd1: https://gist.github.com/hdiwan/29a8d165d294cb1f03db55bff6731a99
[09:44:51] hd1: not sure, why the filenames are alphebetised, but ok
[09:45:26] dminuoso: hd1: That's fine.
[09:46:37] cschneid_: has joined #RubyOnRails
[09:49:58] dminuoso: hd1: Do you want the quick or detailed answer?
[09:50:25] hd1: quick first, detailed would be appreciated, but not necessary
[09:50:51] dminuoso: hd1: You are trying to do an integration test in a controller test.
[09:51:10] dminuoso: The reason it's implicitly an integration test is by fact that your action is using current_user
[09:51:43] hd1: so move it to spec/integration?
[09:55:17] reber: has joined #RubyOnRails
[09:57:46] dminuoso: hd1: Well you have to trigger sign_in at least to stub devise out.
[09:59:54] dminuoso: hd1: Just including that helper does not do anything by itself, it just makes the methods it contains available to your specs.
[10:00:58] dminuoso: That's as far as I can tell.
[10:03:32] hd1: still giving me the same error
[10:03:40] hd1: ACTION leaves it for later
[10:09:15] Ergo: has joined #RubyOnRails
[10:13:02] srinidhi: has joined #RubyOnRails
[10:22:02] cschneid_: has joined #RubyOnRails
[10:22:26] ur5us: has joined #RubyOnRails
[10:24:45] dminuoso: hd1: Whats the purpose of that setup method? This is the one thing Im wondering about.
[10:25:07] dminuoso: hd1: Im guessing you are getting a method_missing exception otherwise arising from the included hook on the helper module?
[10:26:56] dminuoso: hd1: Well a simple solution would be to stub out current_user yourself.
[10:27:57] hd1: thanks,willl look into that after work
[10:28:03] dminuoso: hd1: But I think I got it.
[10:33:03] t0adst00l: has joined #RubyOnRails
[10:33:45] Cavallari: has joined #RubyOnRails
[10:34:07] dminuoso: hd1: At the very least you have to somehow deal with that setup callback.
[10:35:03] za1b1tsu: has joined #RubyOnRails
[10:35:03] dminuoso: using sign_in explicitly would seem to force at least the :warden callback that setup is invoked with
[10:36:50] za1b1tsu: Hello, Im trying to preload some data using includes (session has multiple ratings, and multiple subjects) Subject.includes(:ratings, :subjects)
[10:37:26] za1b1tsu: But I want certain attributes from ratings and subjects, I dont need all data, If I do :ratings[:score], it will look for a score association
[10:37:42] za1b1tsu: Can someone tell me how can I specify the attributes for the associations?
[10:40:25] tbuehlmann: za1b1tsu: I don't think you can select the association's columns that easily. I'd probably preload the associations manually using the preloader
[10:43:23] tbuehlmann: something like this: https://gist.github.com/tbuehlmann/d747212e72da48ffc79d8bbe8dd478e1
[10:43:56] za1b1tsu: tbuehlmann: Ahh I see, is there a big penalty in terms of perfomance if I get more columns that I need from an object?
[10:45:30] t0adst00l: has joined #RubyOnRails
[10:45:37] tbuehlmann: depends on the content's size I guess. I wouldn't care too much for smallish columns
[10:46:29] za1b1tsu: ou lala it does so many queries
[10:47:43] tbuehlmann: can you gist the generated sql of these queries?
[10:51:03] za1b1tsu: https://gist.github.com/bbtdev/bc3f9ba1e553cac8a998b38ae39fc333
[11:00:51] zwliew: has joined #RubyOnRails
[11:08:54] dminuoso: tbuehlmann: Can you imagine, since the beginning of the year I have not vocalized any dissastisfaction abotu rails.
[11:09:31] dminuoso: But then again I have not worked with rails since then.
[11:09:54] za1b1tsu: dminuoso: you think Phoenix/Elixir is better?
[11:11:38] arBmind: has joined #RubyOnRails
[11:12:23] tbuehlmann: dminuoso: give it a day or two :)
[11:16:47] tbuehlmann: oh wait, haven't you heard about https://github.com/stimulusjs/stimulus? you have to have a strong opinion about that one
[11:22:40] dionysus69: has joined #RubyOnRails
[11:24:46] ferr: has joined #RubyOnRails
[11:25:30] dminuoso: What the actual.
[11:27:06] dminuoso: tbuehlmann: While Im a big fan of declarative programming, this is too angularishy for me.
[11:27:23] dminuoso: I don't like magic declarations, I like functional combinators.
[11:28:36] ferr: has left #RubyOnRails: ()
[11:29:55] dminuoso: Also Im not a big fan of abusing getters like this. :(
[11:31:59] dminuoso: Also DOM based bindings are somewhat brittle, as demonstrated by a decade of bad jQuery experiences.
[11:32:56] tbuehlmann: I'll give it a try some time
[11:33:28] dminuoso: Ill do as well, I can definitely see the value of this in traditional rails applications when you just want a more tight coupling between JS and your static views.
[11:34:32] tbuehlmann: I understand it as something between jquery and something more ambitious like vuejs
[11:34:34] dminuoso: I tried experimenting with embedding JS directly into slim, but the inability to process the JS through webpack made me abort.
[11:34:49] tbuehlmann: it should do better than jquery spaghetti code at least
[11:34:58] dminuoso: Absolutely, indeed.
[11:38:10] dminuoso: tbuehlmann: The real PITA for me would be adapting to this weird syntax. The one reason why JSX got me over is because it's just syntax sugared JS, and you can directly interpolate JS (and it's recursively nesteable)
[11:38:20] dminuoso: Allowing you to make use of combinators to express abstract constructs.
[11:39:18] dminuoso: <button data-action="click->hello#greet">Greet</button>
[11:40:10] dminuoso: Ill try it out and let you know tbuehlmann
[11:47:37] tbuehlmann: do you know why name is a getter and not a function in the example?
[11:58:35] za1b1tsu: I see alot of examples on the net about eager loading associations Like Post.where(...).include(...)
[11:58:50] za1b1tsu: but what if I want to eager load Post.where(....)
[12:00:06] za1b1tsu: is it possible?
[12:01:00] uksio: has joined #RubyOnRails
[12:04:37] wethu: has joined #RubyOnRails
[12:06:14] tbuehlmann: what do you mean?
[12:08:33] j0llyr0tten: Apparently the master branch now requires CoffeeScript
[12:09:01] j0llyr0tten: This, in my humble opinion, is not the greatest idea in the world
[12:14:58] cschneid_: has joined #RubyOnRails
[12:16:44] j0llyr0tten: Making CoffeeScript a hard requirement causes bloat
[12:17:15] j0llyr0tten: Not allowing people to --skip-coffee is not great
[12:17:57] j0llyr0tten: Straw poll ! How many people here use the --skip-coffee command line option when making a new Rails app?
[12:21:31] alfiemax: has joined #RubyOnRails
[12:24:35] za1b1tsu: tbuehlmann: For example I have Subjects.where(closed: false). I want to eager loaded, so the data is stable. My only options is arels, right?
[12:32:16] Aherin: has joined #RubyOnRails
[12:40:35] wethu: has joined #RubyOnRails
[12:44:38] t0adst00l: has joined #RubyOnRails
[12:44:42] fschuindt: has joined #RubyOnRails
[12:47:25] dminuoso: tbuehlmann: My best guess is that its just used in a DSL sense, much in the same way how foo= methods exist in Ruby.
[12:47:39] dminuoso: Obviously there's no real reason to use setters or getters.
[12:48:40] dminuoso: tbuehlmann: In the end dynamic getters and setters are more tricky to optimize in v8 (not that the particular use case of stimulus is of interest here, but still)
[12:48:51] dminuoso: (Not sure about SpiderMonkey)
[12:50:21] tcopeland: has joined #RubyOnRails
[12:51:18] dminuoso: tbuehlmann: It's not too terrible though, they do mimic observables.
[12:51:42] dminuoso: That way you get an "assignment" interface, but in reality it acts as an observable
[12:52:15] dminuoso: ACTION shrugs
[12:52:33] dminuoso: At the very least a clean concise way of binding markup to JS is a neat idea.
[12:52:45] dminuoso: Makes it easily greppable too
[12:54:01] cschneid_: has joined #RubyOnRails
[12:55:28] anotherone2: has joined #RubyOnRails
[13:01:22] za1b1tsu: if subjects has many ratings, I can't use Subject.where(ratings: a_ratings_collection)? Is something wrong with my schema??
[13:01:59] dminuoso: za1b1tsu: You can merge relations with ActiveRecord::SpawnMethods#merge
[13:02:09] dminuoso: See http://api.rubyonrails.org/classes/ActiveRecord/SpawnMethods.html#method-i-merge
[13:02:28] dminuoso: za1b1tsu: Also you can use .joins.where(...)
[13:02:56] za1b1tsu: dminuoso: thank you
[13:03:00] dminuoso: i.e. .joins(:foo).where(foos: {bar: 'quux'})
[13:03:22] j0llyr0tten: My bad, --dev option always gives you coffee! This needs documenting but I cannot find where …
[13:03:53] dminuoso: J0llyr0tten: Which command are you talking about?
[13:09:43] crova: has joined #RubyOnRails
[13:13:28] j0llyr0tten: dminuoso: the new command – if you issue --dev and --skip-coffee together, the coffee-related gems don't get included but they are needed because master's client-side code is written in CoffeeScript so the app breaks
[13:16:05] dminuoso: J0llyr0tten: I've dug into the relevant code and I dont see any code reflecting this as intended behavior.
[13:16:10] dminuoso: What exact command did you issue?
[13:20:46] dminuoso: J0llyr0tten: I just tried it, and it installs without coffee script as intended.
[13:21:14] alfiemax: has joined #RubyOnRails
[13:21:59] dminuoso: J0llyr0tten: https://gist.github.com/dminuoso/f3dd259035cea606b2609e13e509646c
[13:25:17] za1b1tsu: Can I make this more pretty (the to_a part): Subject.select(:id).joins(:ratings).where("ratings.id IN (?)", ratings.to_a) ?
[13:25:23] za1b1tsu: ratings is a collection
[13:25:43] za1b1tsu: I mean ActiveRecord::Relation
[13:28:01] dminuoso: what is that where clause supposed to do?
[13:30:04] za1b1tsu: Subject has many ratings, and I want to get the Subjects for the a specific rating activerecord::relation
[13:30:18] za1b1tsu: for ex the subjects for the ratings with ids: 2, 4, 5,7
[13:31:55] cschneid_: has joined #RubyOnRails
[13:43:05] tbuehlmann: za1b1tsu: Subject.joins(:ratings).where(ratings: {id: ratings.select(:id)}) executes one query with a subquery in it. if ratings is already loaded, you can also call za1b1tsu: Subject.joins(:ratings).where(ratings: {id: ratings.map(&:id)}) which will not use a subquery. but then again, you could also include the subject like `ratings = Rating.includes(:subject)` and then just call ratings.map(&:subject)
[13:46:35] za1b1tsu: tbuehlmann: wow, thank you
[13:46:46] za1b1tsu: I think this kinda saved my life
[13:48:22] za1b1tsu: how do you learn stuff like this .where(ratings: {id: ratings.select(:id)} ? I've been reading for 2-3 days about this stuff, all I found is arel code
[13:48:40] za1b1tsu: I mean it doesnt even make sense, pure magic
[13:51:30] za1b1tsu: why where(ratings: ratings) worked without .join and now the syntax is diff, crazt
[13:55:43] tbuehlmann: I probably read about it, no idea where
[13:58:03] dminuoso: I wasnt sure whether that worked with relations and cba to try it out.
[13:58:04] zwliew: has joined #RubyOnRails
[13:58:21] dminuoso: Because tbuehlmann made me write angular without angular.
[14:02:15] jnollette: has joined #RubyOnRails
[14:05:11] iamarun: has joined #RubyOnRails
[14:08:44] cschneid_: has joined #RubyOnRails
[14:13:18] tcopeland: A nice thing about using Arel things like “ratings: some_collection” vs SQL is that Arel will optimize some of those cases; if some_collection only has one element it’ll do an equality comparison rather than an IN clause
[14:13:57] Arkentias: has joined #RubyOnRails
[14:14:38] dminuoso: tcopeland: Until you have to deal with the oracle adapter, in which case stuff breaks real fast when you have arrays with more than 1000 elements =)
[14:14:47] dminuoso: Though I know apeiros has some hack for this that I cant remember.
[14:14:56] tcopeland: innnteresting
[14:15:36] apeiros: I tend to use subselects where possible and find_batch/each_slice where it's not possible
[14:16:02] apeiros: subselect can be composite too: Foo.where(some_id: Bar.funky_scope_here.select(:id))
[14:16:40] apeiros: tcopeland: also any sane query planer will not give a shit on `foo IN (single)` vs. `foo = single`
[14:16:45] dminuoso: apeiros: I wonder whether you can also utilize temporary tables in conjunection with subselects.
[14:17:24] apeiros: dminuoso: you probably could. but afaik oracle doesn't have session local temp tables. I only know those from mssql. am I mistaken? (very well possible)
[14:17:52] tcopeland: apeiros: would you do “some_id: Bar.funky_scope_here.select(:id)” rather than “some_id: Bar.funky_scope_here” ? I think maybe equivalent… fiddling with it to verify…
[14:20:11] apeiros: tcopeland: I think if it's the primary key, you can drop the select(:primary_key)
[14:20:16] apeiros: if it's anything else, you need it
[14:20:41] apeiros: and I haven't yet tried with non-scalar values in pg :D
[14:22:01] apeiros: hm, tom copeland rings a bell and I can't remember why… did you or a namesake write a book?
[14:24:05] tcopeland: apeiros: yup although Dave Copeland (no relation) is probably the more famous Ruby Copeland
[14:24:20] jobewan: has joined #RubyOnRails
[14:24:33] tcopeland: he did the most recent agile web dev and some other books for pragprog
[14:25:16] dminuoso: tcopeland: Just doing some browsing - is pippi aware of loop fusion in lazy enumerators?
[14:26:03] tcopeland: hmmmmm thinking…
[14:26:57] tcopeland: I wasn’t aware of it (!) so I didn’t encode anything into pippi for that… so I’ll say that’s a “no”
[14:27:20] dminuoso: Well you'd have to trace types (or rely on type annotations that we dont have) to even know that you have a lazy enumerator.
[14:27:39] dminuoso: Fair enough. It looks like a nifty tool though.
[14:28:21] tcopeland: the nice thing about pippi is that it’s a runtime tool so all the type information is available
[14:28:24] ur5us: has joined #RubyOnRails
[14:28:37] tcopeland: of course that’s also a not-nice thing since it has to observe running code
[14:28:54] dminuoso: In a way it's actually quite sad. But that doesn't say anything about your tool, but just about Ruby.
[14:29:19] tcopeland: thanks! I have some more checks I want to implement, such as suggesting to replace "foo".gsub(/o/, "") with "foo".remove("o")
[14:30:11] tcopeland: what was the ruby static type thing that the fella at Univ of Md is doing… rdl?
[14:30:30] dminuoso: tcopeland: Yeah.
[14:30:34] tcopeland: https://github.com/plum-umd/rdl#introduction
[14:30:48] tcopeland: really hard for something like that to get traction
[14:31:25] dminuoso: tcopeland: Though considering rubocop or even eslint it's easier to just blindly go against the AST, and let the user disable lines when they know that dynamically the rule misfires.
[14:31:27] alfiemax: has joined #RubyOnRails
[14:31:31] za1b1tsu: In arel can you project attributes without writing the table name everytime? sessions[:id], sessions[:average] etc?
[14:31:35] dminuoso: Or rather CST and not AST.
[14:31:56] dminuoso: tcopeland: https://ro-che.info/ccc/17
[14:33:06] tcopeland: dminuoso: have you read https://www.manning.com/books/type-driven-development-with-idris ? I keep hearing that book referenced in different podcasts… linear types and dependent types and whatnot
[14:33:42] dminuoso: tcopeland: Have not touched Idris yet, but it and Agda have been on my compass for a while now.
[14:34:03] tcopeland: oh interesting, I am not familiar with CST vs AST… reading https://eli.thegreenplace.net/2009/02/16/abstract-vs-concrete-syntax-trees/ now…
[14:35:24] dminuoso: tcopeland: But dependent types are quite crazy. Have seen recent developments introducing them to Haskell even using a lot of tricks.
[14:43:45] EXCHGR: has joined #RubyOnRails
[14:47:13] dviola: has joined #RubyOnRails
[15:01:43] LightStalker: has joined #RubyOnRails
[15:03:11] j0llyr0tten: dminuoso: could it be because i then point the Rails source to master in the Gemfile and reissue a `bundle install' ?
[15:03:38] dminuoso: J0llyr0tten: Probably. If you check my gist you will see how you probably should use it.
[15:04:43] dminuoso: just create a directory with a Gemfile with rails and possibly dependencies on rack and other things, depending on which versions you use, and then just run `bundle exec rails new . --dev --force`
[15:05:05] dminuoso: Though matthewd might know more, it's not well documented.
[15:05:30] j0llyr0tten: dminuoso: i checked your gist, i'm pretty sure that's what i did (can't remember if i used --force)
[15:06:07] dionysus69: has joined #RubyOnRails
[15:06:26] j0llyr0tten: i think the difference, as i say, is that i then point the Gemfile to master on Github rather than to local gems
[15:07:24] j0llyr0tten: and the reason i do that is to track the development branch
[15:09:33] cstls: has joined #RubyOnRails
[15:11:16] cschneid_: has joined #RubyOnRails
[15:12:43] krawchyk: has joined #RubyOnRails
[15:15:30] sawdustofmind1: has joined #RubyOnRails
[15:21:01] jobewan: has joined #RubyOnRails
[15:22:24] dminuoso: J0llyr0tten: mm isnt that equivalent to --edge then?
[15:22:36] dminuoso: J0llyr0tten: Either way, I had it point at `master` on github too.
[15:22:47] dminuoso: J0llyr0tten: It doesn't have to be a local repository, just any git repository that Bundler can follow.
[15:31:03] mikecmpbll: has joined #RubyOnRails
[15:31:10] walidvb: has joined #RubyOnRails
[15:32:56] walidvb: I have Links, Users, and LinkUserAssignment. I'm trying to get a list of my links such as each link would contain a key "users" which would contain each user(or some of their fields)
[15:48:38] za1b1tsu: Inside where in queries, should I use arrays, scopes or activeRecord::relations?
[15:49:43] za1b1tsu: which can be considered more efficient when it comes to massive amount of data?
[15:49:55] dminuoso: za1b1tsu: relations if in doubt.
[15:50:31] dminuoso: za1b1tsu: reason is that a relation is lazy and its nodes can be fused according to tcopeland.
[15:50:44] dminuoso: a scope is equivalent in that sense.
[15:50:52] dminuoso: Or at the very least I'd expect it to be
[15:51:32] za1b1tsu: So stuff like this is not that good https://gist.github.com/bbtdev/52ce13f1a110a1bcf64dae6f61cc6844
[15:55:38] tcopeland: yeah generally a scope returns a relation; a scope can be defined to return something else but that will break expectations since then it can’t be chained, e.g. scope :most_recent_featured, -> { featured.last } returns an ActiveRecord::Base subclass. sometimes those can be nicely replaced with a has_one
[15:56:41] za1b1tsu: I need to get data, do some calculations and then update the db
[15:56:59] tcopeland: and za1b1tsu yeah it might be worth replacing Rating.where(session_id: @sessions.map { |session| session[:id]}) with Rating.where(session_id: @sessions)
[15:57:15] tcopeland: well or even Rating.where(session: @sessions)
[15:57:31] za1b1tsu: I was planning to get data as hashes, calculate on hashes, and update with Klass.update(hash)
[15:57:41] tcopeland: since Active Record will infer the id from the association name
[15:57:55] mikecmpb_: has joined #RubyOnRails
[15:59:00] za1b1tsu: tcopeland: so I should make @sessions as an activeRecord: Relations
[16:01:27] za1b1tsu: something like this https://gist.github.com/bbtdev/aefecf8b54a921586d4a6510a35babeb
[16:06:05] tcopeland: yes or perhaps: @sessions = sessions.map {|x| x.attributes.slice("id", “average”) }
[16:06:33] tcopeland: although that’s less efficient than your previous code since it’s not using pluck… so maybe not a good idea
[16:09:37] za1b1tsu: tcopeland: should I use activeRecord::relations for calculations as well? And then update the members?
[16:10:01] za1b1tsu: I was planing to do the calculations in a hash and then use Session.udate(hash)
[16:10:27] jobewan: has joined #RubyOnRails
[16:10:52] Tempesta: has joined #RubyOnRails
[16:10:55] Dimik: has joined #RubyOnRails
[16:12:36] tcopeland: hm I’m not sure, might depend on your situation…
[16:16:13] za1b1tsu: Session.update(hash) is so much sexier than sessions.each { |s| s.save! }
[16:29:19] kapil___: has joined #RubyOnRails
[16:31:19] SteenJobs: has joined #RubyOnRails
[16:34:35] xlymian: has joined #RubyOnRails
[16:34:46] Torrone: has joined #RubyOnRails
[16:38:50] Torrone: hello, I'm working with the latest version of rails and puma in development environment. As of lately, my dev server started becoming very slow ( and unnerving ) :~) . In the rails logs I read 'Started GET/POST/ETC' and it stays like that for a while, that's where the slowness happens. I was wondering if I can see what it's doing there because maybe I can make it skip something that is not absolutely necessary and is ran there. D
[16:38:50] Torrone: o you know how to do this? Thanks :-)
[16:44:10] Exuma: has joined #RubyOnRails
[16:44:11] cagomez: has joined #RubyOnRails
[16:44:34] xlymian: has left #RubyOnRails: ("WeeChat 2.0.1")
[16:51:16] NoGodDamnIdea: has joined #RubyOnRails
[16:52:49] Barrt: has joined #RubyOnRails
[16:56:49] cagomez: where do I find docs like http://api.rubyonrails.org/ but for previous versions?
[16:57:27] fschuindt: cagomez: http://api.rubyonrails.org/v4.0.0/
[16:57:39] cagomez: ah thanks fschuindt
[17:03:14] Torrone: has joined #RubyOnRails
[17:05:49] Exuma: has joined #RubyOnRails
[17:07:41] darkhanb: has joined #RubyOnRails
[17:11:47] one_zero: has joined #RubyOnRails
[17:28:43] Cache_Money: has joined #RubyOnRails
[17:34:55] dminuoso: fschuindt: Mmm there does not seem to be some explorer interface for different versions.
[17:37:03] fschuindt: dminuoso: yup
[17:39:19] conta: has joined #RubyOnRails
[17:40:17] [Butch]: has joined #RubyOnRails
[17:51:35] [Butch]: has joined #RubyOnRails
[17:57:12] workmad3: has joined #RubyOnRails
[18:05:55] hahuang65: has joined #RubyOnRails
[18:09:09] orbyt_: has joined #RubyOnRails
[18:11:21] hahuang65: has joined #RubyOnRails
[18:12:21] uks: has joined #RubyOnRails
[18:16:53] blindMoe: has joined #RubyOnRails
[18:17:57] blindMoe: I am updating an older app from rubocop .42 to .52.1. One rule in rubocop-rspec that is bugging me is it wanting me to "paranthesize the param change". The line is this: expect { subject }.not_to change { user.emails.first.confirmed? }
[18:18:29] blindMoe: but when I switch it to expect { subject }.not_to change(user.emails.first.confirmed?) I end up getting an error because .confirmed? is nil in some of the tests ( it is part of a shared example )
[18:18:59] blindMoe: curious if maybe I am just mis-reading the rule description and am doing it wrong or if someone knows what needs to be done?
[18:20:20] IanMalcolm: has joined #RubyOnRails
[18:35:17] sent-hil: has joined #RubyOnRails
[18:40:19] j0llyr0tten: dminuoso: where the code for `rails new' ?
[18:42:26] dminuoso: J0llyr0tten: its across the railties
[18:43:16] dminuoso: J0llyr0tten: or rather `railties` consists of some parts, and the cli is one of it.
[18:43:39] [Butch]: has joined #RubyOnRails
[18:47:51] sameerynho: has joined #RubyOnRails
[18:47:51] mtkd: has joined #RubyOnRails
[18:51:02] orbyt_: has joined #RubyOnRails
[19:06:29] DaniG2k: has joined #RubyOnRails
[19:06:46] DaniG2k: has left #RubyOnRails: ()
[19:06:53] DaniG2k: has joined #RubyOnRails
[19:07:09] DaniG2k: has left #RubyOnRails: ()
[19:07:37] sawdustofmind1: Hi all. I have a list of fixtures and I want to use them all into my test. What should I do?(rails 5)
[19:08:03] DaniG2k: has joined #RubyOnRails
[19:11:30] dminuoso: sawdustofmind1: If they are in test/fixtures, nothing.
[19:15:02] mikecmpbll: has joined #RubyOnRails
[19:19:05] sawdustofmind1: dminuoso: Hm... Actually so... Sometimes I thinks so hard... Thanks)
[19:22:41] codepete: has joined #RubyOnRails
[19:27:01] hahuang65: has joined #RubyOnRails
[19:28:14] mikecmpb_: has joined #RubyOnRails
[19:31:42] tectonic: has joined #RubyOnRails
[19:33:25] mikecmpbll: has joined #RubyOnRails
[19:34:54] crova: Greetings folks, happy new year! I'm facing a problem with this https://gist.github.com/crova/68c6dc1bf8e03e20cc7c088d66230938 I can't seem to find what is going wrong. Same piece of code works for one case but does not work for the other. If someone could give it a look, cheers
[19:35:12] dminuoso: crova: please include a full stacktrace
[19:36:30] za1b1tsu: has joined #RubyOnRails
[19:36:57] crova: dminuoso, included if this was what you were asking, I can also add the result of the merge
[19:37:22] dminuoso: k thats fine, just wanted to make sure the error actually comes from the spot (perhaps a bit redundant but anyway)
[19:39:00] crova: dminuoso, no worries mate. What bugs me is that on irb I get the object I'm supposed to from the merge, but on the view things go wrong
[19:41:42] dminuoso: crova: What database adapter are you using?
[19:42:32] dminuoso: crova: Also is it possible you mispasted the view_for_wm_sweep.html.erb file?
[19:42:55] crova: dminuoso, postgresql
[19:44:34] crova: dminuoso, regarding the view, I don't reckon, but I will double check if everything looks as it should
[19:45:20] dminuoso: crova: If its not then something is wrong, because both views seem to use @wm_gmail_e_cia_all
[19:45:55] crova: dminuoso, yes I did, one second, my bad
[19:46:46] crova: dminuoso, updated with correct view for sweep
[19:47:06] dminuoso: crova: Because this is starting to look strange. Did you paste the code in the entirety?
[19:47:30] crova: nope, just the line which raises the error
[19:47:49] DrYockel: has joined #RubyOnRails
[19:49:05] crova: dminuoso, updated gist with 2 files with full view for both cases
[19:49:05] dminuoso: crova: Also, what interface is that .merge with a block?
[19:50:11] dminuoso: Is that from some custom module?
[19:51:02] crova: dminuoso, I needed to sum values from 2 different hashs (with same keys) to get the total result
[19:51:09] amperry: has joined #RubyOnRails
[19:52:04] amperry: hey folks, 'passenger-install-apache2-module' is telling me that I need to run (sudo) 'yum install httpd-devel' on CentOS, but
[19:52:12] crova: dminuoso, updated gist with full methods for both cases
[19:52:16] dminuoso: crova: https://github.com/rails/rails/blob/master/activerecord/lib/active_record/relation/spawn_methods.rb#L31-L39
[19:52:24] dminuoso: crova: This thing completely ignores any block you pass it.
[19:52:31] amperry: when I try to do that, I get the error: "No package httpd-devel available."
[19:52:32] dminuoso: crova: I think "merge" doesnt do what you think it does.
[19:53:15] dminuoso: crova: .where produces a relation, not some array or hash. This .merge fuses the internal arel nodes together in the sense of "combining where clauses", losely speaking.
[19:53:56] dminuoso: crova: http://api.rubyonrails.org/classes/ActiveRecord/SpawnMethods.html#method-i-merge
[19:54:01] dminuoso: this is the documentation of what you are using.
[19:54:50] dminuoso: My eyes completely skipped your kpi method, sorry.
[19:55:15] crova: I was about to talk about it
[19:55:18] arBmind: has joined #RubyOnRails
[19:55:33] crova: but I appreciate the info nonetheless, I'll take a look on that regardless
[19:55:45] dminuoso: crova: Ah okay yeah the original pastie didnt have the full relevant code, this looks better.
[19:55:55] dminuoso: crova: Though I think its still a mispaste.
[19:56:10] dminuoso: Or do you actually have in-method method definition?
[19:56:30] crova: yes, it is an in-method
[19:57:40] crova: even if I could probably strip all the methods and only use one (not sure what I was thinking back then)
[19:58:02] dminuoso: crova: Oh yeah you just have a variable confusion.
[19:58:15] dminuoso: crova: https://gist.github.com/crova/68c6dc1bf8e03e20cc7c088d66230938#file-full_methods_controller-rb-L26
[19:58:18] dminuoso: crova: This is a merged hash
[19:58:34] dminuoso: (Which contains that fancy hash with kpi stuff)
[19:58:56] dminuoso: https://gist.github.com/crova/68c6dc1bf8e03e20cc7c088d66230938#file-full_sweep_view-html-erb-L183
[19:59:12] dminuoso: This then calls .each, which works because Hash happens to have it
[19:59:32] dminuoso: Hash#each calls its block with a pair [key, value] for each key/value pair
[19:59:58] dminuoso: And because of how ruby works, you happen to get this pair first: https://gist.github.com/crova/68c6dc1bf8e03e20cc7c088d66230938#file-sib_transac_controller-1-rb-L3
[20:00:09] dminuoso: Giving you [:requests, 0]
[20:00:52] dminuoso: The link_to do some weird unwanted crap but dont throw, but the first thing that doesnt work with that array is: https://gist.github.com/crova/68c6dc1bf8e03e20cc7c088d66230938#file-full_sweep_view-html-erb-L85
[20:01:54] dminuoso: You probably meant to use @wm_sweep_follow_up_all_to_update or one of those.
[20:03:48] crova: dminuoso, I guess I'll take a break and re-write from scratch to make sure I'm not misusing anything there
[20:04:13] dminuoso: crova: You probably might want to modularlize more.
[20:04:47] dminuoso: crova: Also the next time just paste the whole code uncut. You managed to very elegantly leave away all the relevant parts. :-)
[20:05:30] crova: yes I should, I'm still learning this whole thing (and I really appreciate all the info you provided here). I tend to write some poor poor code
[20:05:55] crova: dminuoso, I will, I thought I was saving you from reading some gibberish but I guess I was dead wrong lol
[20:09:36] helpa: has joined #RubyOnRails
[20:09:49] crova: sure thing dminuoso, thanks again mate
[20:13:39] t0adst00l: has joined #RubyOnRails
[20:17:04] desperek: has joined #RubyOnRails
[20:33:44] conta: has joined #RubyOnRails
[20:40:11] Kilo`byte: has joined #RubyOnRails
[20:47:20] cagomez: has joined #RubyOnRails
[20:50:27] orbyt_: has joined #RubyOnRails
[20:57:33] amperry: "This installer will guide you through the entire installation process. It shouldn't take more than 3 minutes in total." -- 1 hour later...
[20:59:16] amperry: so I'm having trouble installing passenger on CentOS
[20:59:35] havenwood: amperry: What trouble are you running into?
[20:59:42] desperek: hi, cann i do that
[20:59:43] desperek: has_many :invites
[20:59:43] desperek: belongs_to :invite
[21:01:05] amperry: havenwood: I'm running passenger-install-apache2-module, and (after manually installing and compiling prerequisites) I get an error:
[21:01:43] amperry: havenwood: "You are about to validate Phusion Passenger against the following Apache installation: apxs2: /usr/bin/apxs However, this Apache installation appears to be broken,..."
[21:02:52] za1b1tsu: has joined #RubyOnRails
[21:04:07] amperry: the installer orginally had me run yum to install some prerequisites, and yum couldn't install httpd-devel, so I followed the instructions here: https://forums.cpanel.net/threads/install-httpd-devel.594631/
[21:04:45] amperry: I don't know if that's why it's looking for apxs2, or if that has anything to do with anything.
[21:04:53] cagomez: has joined #RubyOnRails
[21:07:18] dionysus69: has joined #RubyOnRails
[21:07:57] mikecmpb_: has joined #RubyOnRails
[21:08:03] IanMalcolm: has joined #RubyOnRails
[21:10:17] alfiemax: has joined #RubyOnRails
[21:10:24] fryguy: amperry: why did you pick passenger?
[21:12:31] amperry: fryguy: it had good press... is there a reason not to?
[21:12:50] fryguy: puma is just as performant, if not more so, and much easier to install
[21:14:37] amperry: puma is, in fact, already installed. What do I need to do next? (I'm following this, btw: https://pragprog.com/book/rails5/agile-web-development-with-rails-5)
[21:15:14] fryguy: you run it...
[21:16:21] amperry: you mean, run "rails server", or something puma-specific?
[21:17:16] fryguy: rails server will probably run puma for you
[21:19:02] Kilo`byte: has joined #RubyOnRails
[21:19:09] amperry: then my problem is probably that I haven't configured the server properly, because running that doesn't actually allow me to run the app.
[21:20:45] amperry: I can't get to the server in my browser, in other words. "This site can’t be reached". I'm going straight by the ip address and port 3000.
[21:24:36] fryguy: well, what interface is it listening on?
[21:26:03] amperry: I find this out by...
[21:26:09] fryguy: looking at it's output when it starts
[21:26:32] amperry: Listening on tcp://
[21:26:53] fryguy: ok, so that's not the problem
[21:27:05] fryguy: are there firewall rules in place blocking access?
[21:27:15] amperry: none that I set up.
[21:27:39] fryguy: was one maybe set up via some other process?
[21:28:43] amperry: possibly, but I doubt it.
[21:29:21] amperry: I was hoping that passenger's promise to tell me what I needed to edit into my apache config files would help, because I don't know what to put there.
[21:30:04] cagomez: has joined #RubyOnRails
[21:30:06] fryguy: maybe you should consider use a more hands-off hosted solution. seems like you don't have the experience with systems administration to handle this? heroku is a pretty reasonable hands-off offering
[21:31:08] amperry: Stuck with what I got. Tried heroku before, was equally painful.
[21:31:40] amperry: I'll see what I can dig up re: setting up apache for rails
[21:42:23] amperry: well, sonofabeach, it suddenly works, with no config changes... (really got to record my steps when I do this, my memory is too selective).
[21:42:46] fryguy: that's what configuration management systems are for
[21:46:35] mtkd: has joined #RubyOnRails
[21:47:29] dopie: has joined #RubyOnRails
[22:02:03] tcopeland: has joined #RubyOnRails
[22:05:36] sawdustofmind1: How often does C usage into ruby happen useful in practice?
[22:08:11] talntid: has joined #RubyOnRails
[22:10:03] jokke: has joined #RubyOnRails
[22:11:47] Radar: sawdustofmind1: I've only used it once in my decade-long career to fix a bug in a gem.
[22:15:18] alfiemax: has joined #RubyOnRails
[22:20:02] sawdustofmind1: Radar: Hm... Strange... It seemed to me such a powerful option that can highly improve the performance... Well.. thx
[22:20:45] Radar: sawdustofmind1: Ruby is Fast Enough™ given the right hardware. If you have problems that you want to use C to solve I'd consider using Elixir/Rust/Go for that instead.
[22:32:03] gambl0re: has joined #RubyOnRails
[22:33:38] NoGodDamnIdea: has joined #RubyOnRails
[22:38:03] sawdustofmind1: has left #RubyOnRails: ()
[22:41:04] maryo: has joined #RubyOnRails
[22:44:19] cnk: has joined #RubyOnRails
[22:55:47] mikecmpbll: has joined #RubyOnRails
[23:08:00] jobewan: has joined #RubyOnRails
[23:22:50] nfsnobody: has joined #RubyOnRails
[23:31:17] blindMoe: has joined #RubyOnRails
[23:32:48] blindMoe: with a rails action controller, if I do something like before_action :foo only: [:index, :show] but index is not defined in this class, rubocop now wants me to define it. I can just do: def index; end but would should I be doing def index; super; end ?
[23:40:40] Exuma: has joined #RubyOnRails
[23:50:32] Exuma: has joined #RubyOnRails