« Back to channel list

#RubyOnRails - 06 February 2019

« Back 1 day Forward 1 day »
[00:03:32] orbyt_: has joined #RubyOnRails
[00:16:28] axilaris: has joined #RubyOnRails
[00:17:01] axilaris: hi, i have one EC2 aws server running puma for my RoR app. its setup by one of my staff that left
[00:17:17] axilaris: i want to know if its possible to have 2 RoR app in the server ?
[00:17:26] axilaris: and what should be done
[00:17:37] axilaris: its an ubuntu server running with nginx
[00:18:11] axilaris: it should be possible right ? similar to Apache with Virtualhost
[00:40:22] quazimodo: has joined #RubyOnRails
[01:26:30] yoshie902a: has joined #RubyOnRails
[01:26:39] yoshie902a: Radar: you around?
[01:26:55] xall: has joined #RubyOnRails
[01:28:58] yoshie902a: Radar: Can you render a partial from a form builder method? https://ghostbin.com/paste/atvjj
[01:50:39] orbyt_: has joined #RubyOnRails
[02:14:30] tdy: has joined #RubyOnRails
[02:32:37] mheld: has joined #RubyOnRails
[02:36:33] orbyt_: has joined #RubyOnRails
[02:37:04] yoshie902a: has left #RubyOnRails: ()
[03:08:31] dustinm`: has joined #RubyOnRails
[03:13:56] Saukk: has joined #RubyOnRails
[03:22:28] axilaris: has joined #RubyOnRails
[03:58:06] kapil____: has joined #RubyOnRails
[04:09:59] braincrash: has joined #RubyOnRails
[04:14:10] ellcs: has joined #RubyOnRails
[04:22:00] v01d4lph4: has joined #RubyOnRails
[04:37:55] v01d4lph4: has joined #RubyOnRails
[04:38:52] v01d4lph4: has joined #RubyOnRails
[04:39:54] v01d4lph4: has joined #RubyOnRails
[04:42:02] SteenJobs: has joined #RubyOnRails
[04:48:34] ellcs: has joined #RubyOnRails
[04:49:23] srinidhi: has joined #RubyOnRails
[04:57:58] MrCrackPotBuilde: has joined #RubyOnRails
[05:11:45] quazimodo: has joined #RubyOnRails
[05:23:35] ghormoon: has joined #RubyOnRails
[05:41:26] MrCrackPotBuilde: has joined #RubyOnRails
[05:50:21] uks: has joined #RubyOnRails
[05:51:11] elcontrastador: has joined #RubyOnRails
[06:05:31] syndikate: I see this method #with_responders in a codebase I am working on but I can't figure where it is coming from. It's being called on ActiveRecord collection object
[06:18:14] conta: has joined #RubyOnRails
[06:22:03] syndikate: TLDR; Need info on `with_responders` method
[06:25:00] syndikate: Correction - it's a relation object
[06:25:09] reber: has joined #RubyOnRails
[06:34:55] syndikate: My bad everyone, feel so stupid right now. There was a concern written for some other context but used the same naming
[06:35:22] syndikate: Grep failed and I didn't notice
[06:35:27] syndikate: On local code
[06:44:52] orbyt_: has joined #RubyOnRails
[06:47:30] lunarkitty7: has joined #RubyOnRails
[06:53:35] srinidhi: has joined #RubyOnRails
[07:06:21] hahuang6-: has joined #RubyOnRails
[07:07:07] pavelz: https://mymodernmet.com/yarn-artist-liisa-hietanen/?fbclid=IwAR0VHhK3s7_0ZSDJMOQfQUjt4Un5bKi08iSDBjrWwBAfHsrN6kbia8wZr78
[07:18:44] za1b1tsu: has joined #RubyOnRails
[07:18:44] duderonomy: has joined #RubyOnRails
[07:25:46] mangold: has joined #RubyOnRails
[07:54:41] kapil____: has joined #RubyOnRails
[07:57:35] apparition: has joined #RubyOnRails
[08:08:53] mangold: has joined #RubyOnRails
[08:09:23] status402: has joined #RubyOnRails
[08:17:57] kvda: has joined #RubyOnRails
[08:18:55] kvda: Hi there, how do I access config locales i18n in my models? Specifically I need the hash storing the codes and labals, ie. "en: English"
[08:20:08] kvda: Seems like I18n.t("i18n.locale.name.en") will do the job.
[08:21:16] duderonomy: has joined #RubyOnRails
[08:25:07] status402_: has joined #RubyOnRails
[08:25:21] lankanmon: has joined #RubyOnRails
[08:31:12] Sylario: has joined #RubyOnRails
[08:40:30] mangold: has joined #RubyOnRails
[09:06:00] srinidhi: has joined #RubyOnRails
[09:17:45] FastJack: has joined #RubyOnRails
[09:24:44] pierrethierry: has joined #RubyOnRails
[09:26:49] gambl0r3: has joined #RubyOnRails
[09:31:25] Ergo: has joined #RubyOnRails
[09:32:20] lunarkitty7: has joined #RubyOnRails
[09:34:32] pierrethierry: has joined #RubyOnRails
[09:36:14] helpa: has joined #RubyOnRails
[09:36:43] helpa: has joined #RubyOnRails
[09:39:39] lunarkitty7: has joined #RubyOnRails
[09:44:17] Guest16678: has joined #RubyOnRails
[09:49:18] fox_mulder_cp: pierrethierry yes, you can read rails guied. or as example, some like this https://stackoverflow.com/questions/17894688/has-many-belongs-to-relation-in-active-record-migration-rails-4
[09:50:29] fox_mulder_cp: all relations in models is a relations in database too. via foreign keys
[09:50:34] xall: has joined #RubyOnRails
[09:57:58] tbuehlmann: `SomeModel.first.inspect` displays timestamps using the database configured timezone, not the application configured timezone. `SomeModel.first.created_at` correctly displays the timestamp using the application timezone, as expected. the code for the inspection is here: https://github.com/rails/rails/blob/v5.2.2/activerecord/lib/active_record/attribute_methods.rb#L352
[09:58:05] tbuehlmann: any idea why that would be useful?
[10:02:35] kvda: has joined #RubyOnRails
[10:08:44] roshanavand: has joined #RubyOnRails
[10:10:44] Jervis_: has joined #RubyOnRails
[10:17:44] mikecmpbll: has joined #RubyOnRails
[10:35:28] lankanmon: has joined #RubyOnRails
[10:35:53] v01d4lph4: has joined #RubyOnRails
[10:36:30] v01d4lph4: has joined #RubyOnRails
[10:37:46] v01d4lph4: has joined #RubyOnRails
[10:38:44] v01d4lph4: has joined #RubyOnRails
[10:55:25] gambl0r3: has joined #RubyOnRails
[11:03:37] srinidhi: has joined #RubyOnRails
[11:17:27] dviola: has joined #RubyOnRails
[11:18:47] srinidhi: has joined #RubyOnRails
[11:32:14] Dbugger: has joined #RubyOnRails
[11:32:54] conta: has joined #RubyOnRails
[11:34:58] pierrethierry: has joined #RubyOnRails
[11:47:06] status402: has joined #RubyOnRails
[11:52:10] lankanmon: has joined #RubyOnRails
[11:52:40] apparition: has joined #RubyOnRails
[11:53:49] Guest16678: has joined #RubyOnRails
[11:55:32] ariedler: has joined #RubyOnRails
[11:56:55] ariedler: has joined #RubyOnRails
[11:59:27] Technodrome: has joined #RubyOnRails
[12:02:03] Guest16678: has joined #RubyOnRails
[12:06:37] Hess: has joined #RubyOnRails
[12:16:45] Guest16678: has joined #RubyOnRails
[12:24:35] jottr: has joined #RubyOnRails
[12:33:47] lexileo: has joined #RubyOnRails
[12:34:40] blackmesa: has joined #RubyOnRails
[12:41:03] segy: has joined #RubyOnRails
[12:45:48] guyzmo: hi, got a quick question with AR queries: I got a has_many association like: `class A do has_many :foobars end` with a model foobar with an attribute x. I want to make a scope selecting all the As for which the first Foobar item has x
[12:45:58] guyzmo: set to nil
[12:46:29] guyzmo: how could I make such a scope/query with AR?
[12:53:34] guyzmo: hm I guess I could do with a .group(:id, 'foobars.x').having('foobars.x is null')
[12:54:45] Guest16678: has joined #RubyOnRails
[12:57:03] guyzmo: nope, not even close :-/
[12:59:33] blackmesa: has joined #RubyOnRails
[13:00:11] tbuehlmann: guyzmo: "first" an in ordered by foobars.created_at DESC?
[13:08:35] guyzmo: hm… the group/having is giving me the list of As with foobars containing least one x set to nil, so I can use that for another scope I need...
[13:09:03] guyzmo: tbuehlmann - yup, I thought about something like that, but how can I express that in a single query?
[13:09:28] |RicharD|: has joined #RubyOnRails
[13:11:03] guyzmo: tbuehlmann - actually I got a `foobar_position` to enforce the order, but for the sake of the discussion we can consider the first of the query result (whatever the order is)
[13:17:07] tbuehlmann: could be this: A.joins(:foobars).order(as.id, foobars.created_at).select('DISTINCT ON(projects.id) projects.*').where(foobars: {title: nil})
[13:17:34] tbuehlmann: although that might be wrong, I'm not sure whether where is applied before or after distinct on :\
[13:23:03] za1b1tsu: has joined #RubyOnRails
[13:28:43] greengriminal: has joined #RubyOnRails
[13:29:48] greengriminal: Hey all quick question regarding adding validation on a `belongs_to` association. Is there any actual difference between: https://gist.github.com/davidpatters0n/314f4d7e98e954c671d69e2b4dd2feda
[13:30:22] tbuehlmann: guyzmo: is the foobar_position absolut? as in: the first foobar has foobar_position 0?
[13:30:45] greengriminal: Ah got my answer I think: using `required` option: Validates the association itself, not the id
[13:31:10] tbuehlmann: greengriminal: wanted to write that, I think that's the case
[13:32:38] greengriminal: Which brings me to my next question, which one makes more sense to use.
[13:34:11] greengriminal: I mean there's no harm in using both, because then that way you validate that the association exists & the foreign key exists too.
[13:35:49] tbuehlmann: if you only care about the presence of any number, go for `bar_id`. if you care about the presence of the actual foreign record, got for `bar`. either way, you shoud have a foreign key constraint on your database
[13:40:51] greengriminal: What if you're using a nosql db such as mongodb.
[13:41:23] greengriminal: in the case of a rails app we're using mongoid.
[13:42:53] Sylario: For complicated query you should start in SQL(or mongodb) and then translate it in AR
[13:43:26] gregf_: has joined #RubyOnRails
[13:49:28] pierrethierry: has joined #RubyOnRails
[13:49:42] liya: has left #RubyOnRails: ("Leaving")
[13:53:22] guyzmo: tbuehlmann - nope, foobar_position is unique for a given foobar_id
[13:54:15] guyzmo: tbuehlmann - I've been discussing about it with a colleague, and I could use a MIN(foobar_position) in a subquery… I'm not excited about using a subquery, though
[13:55:15] blackmesa: has joined #RubyOnRails
[13:55:31] guyzmo: if only I could do a `having('min(foobars).x is null')` that would be great ^^
[13:55:57] tbuehlmann: guyzmo: tell me you're using postgres
[13:57:46] Sylario: guyzmo : do a subquery selecting foobars.parent_id and max(foobars.order_value) and group by parent_id
[13:57:48] guyzmo: is there anything else than postgres ? :)
[13:58:45] guyzmo: sylario - yup, that's what I'm heading to
[13:59:07] tbuehlmann: got something for you then, just a sec
[14:00:32] Sylario: guyzmo for subquery you can do : Bar.where('bars.id in #{suquery.to_sql})
[14:03:13] tbuehlmann: trickier than expected given that there's a join
[14:08:37] v01d4lph4: has joined #RubyOnRails
[14:09:07] tbuehlmann: A.from('(SELECT as.*, foobars.x AS foobar_x, row_number() OVER (PARTITION BY as.id ORDER BY foobars.created_at DESC) FROM as INNER JOIN "foobars" ON "foobars"."project_id" = "as"."id") as').where(row_number: 1, foobar_x: nil)
[14:09:42] tbuehlmann: I used two of my sandbox models and renamed them to A/as and foobars. this will probably crash as "AS" has a certain meaning in SQL. but you'll get the idea
[14:10:54] tbuehlmann: I'm using a partition so each group of foobars per a get a row_number (1, 2, 3, ...). having that, you can simply do a where(row_number: 1, foobar_x: nil). that foobar_x thingy is a bit hacky and there's probably a better way, but it worked in my example
[14:11:52] guyzmo: I think I haven't I've ever used over/partition in SQL
[14:12:31] guyzmo: or if I did it was in SQL class a decade ago :-p
[14:13:20] guyzmo: thank you a lot, and as a double bonus, I've (re?)learned something today :)
[14:13:28] tbuehlmann: you're welcome :)
[14:14:44] guyzmo: oh, and is `A.from()` an AR idiom to convert some random SQL output into a model?
[14:17:23] tbuehlmann: it changes the FROM part of the query
[14:19:25] guyzmo: so as I'm at it : is there a better way to output something like `A.where(id: B.somequery_that_returns_A_ids)` to basically tell ActiveRecord that I want to cast the query's output to some other model?
[14:21:08] tbuehlmann: when Foo.has_many :bs: Foo.where(B.select(:a_id))
[14:21:17] tbuehlmann: this will only be one query (including a subquery)
[14:21:33] tbuehlmann: eh, :foo_id, not :a_id :)
[14:23:10] guyzmo: so the A.where is the way to go
[14:23:18] guyzmo: double thanks :)
[14:32:59] haxx0r: has joined #RubyOnRails
[14:33:05] haxx0r: installing old spreecommerce with rails 4.1
[14:33:11] haxx0r: rake db:create fails
[14:33:27] haxx0r: tim@vm:~/rails/multistore$ rake db:create
[14:33:28] haxx0r: Couldn't create database for {"adapter"=>"mysql2", "database"=>"multistore_development", "pool"=>5, "username"=>"root", "password"=>"1234"}, {:charset=>"utf8", :collation=>"utf8_unicode_ci"}
[14:34:21] haxx0r: i've never seen that before tho. might have todo with mysql 5.7, just freshly installed that in my VM
[14:35:28] haxx0r: maybe has todo that i need to run "sudo mysql -u" instead of without sudo?
[14:36:06] haxx0r: mysql Ver 14.14 Distrib 5.7.25, for Linux (x86_64) using EditLine wrapper
[14:38:00] haxx0r: results in /home/tim/.rvm/gems/ruby-2.1.9/gems/mysql2-0.3.21/lib/mysql2/client.rb:70:in `connect': Access denied for user 'root'@'localhost' (Mysql2::Error)
[14:38:43] haxx0r: however, if i "sudo mysql"it will work. if i just "mysql" i always get access denied
[14:38:52] haxx0r: mysql -u root -p1234
[14:38:52] haxx0r: ERROR 1698 (28000): Access denied for user 'root'@'localhost'
[14:44:35] pierrethierry: has joined #RubyOnRails
[14:45:23] guyzmo: haxx0r - https://askubuntu.com/questions/766334/cant-login-as-mysql-user-root-from-normal-user-account-in-ubuntu-16-04
[14:46:11] guyzmo: by default when you connect as root, it's not asking for a password as it uses a unix socket to connect, and just checks that you're connecting from a superuser account (aka root)
[14:46:41] guyzmo: so it's likely that the 1234 password is wrong
[14:47:49] guyzmo: and anyway, you'd better create an user for your project with enough privileges for rake db:create to do its job, which AFAICT does not need to be having full privileges over the DBMS
[14:48:22] guyzmo: more exactly that's the answer you'll want: https://askubuntu.com/a/801950/583565
[14:51:34] srinidhi: has joined #RubyOnRails
[14:57:45] ariedler: has joined #RubyOnRails
[15:01:48] status402: has joined #RubyOnRails
[15:04:35] status402_: has joined #RubyOnRails
[15:14:25] Sirecote: has joined #RubyOnRails
[15:24:08] kapil____: has joined #RubyOnRails
[15:32:21] elcontrastador: has joined #RubyOnRails
[15:34:16] jottr: has joined #RubyOnRails
[15:46:08] duderonomy: has joined #RubyOnRails
[15:57:20] grvgr: has joined #RubyOnRails
[16:02:22] tdy: has joined #RubyOnRails
[16:31:12] MrCrackPotBuilde: has joined #RubyOnRails
[16:38:58] jottr: has joined #RubyOnRails
[16:40:44] orbyt_: has joined #RubyOnRails
[16:46:18] v01d4lph4: has joined #RubyOnRails
[16:49:32] conta: has joined #RubyOnRails
[16:56:38] silent_freak: has joined #RubyOnRails
[16:57:44] uksio: has joined #RubyOnRails
[17:03:50] uks: has joined #RubyOnRails
[17:21:52] Saukk: has joined #RubyOnRails
[17:28:12] aldodelgado: has joined #RubyOnRails
[17:33:44] aldodelgado: Question? Anyone know if the google+ API shutdown will effect people who are using googleauth to just login? I cant seem to find a straight answer. https://developers.google.com/+/integrations-shutdown
[17:34:13] Aherin: has joined #RubyOnRails
[17:34:36] aldodelgado: looks like the endpoints/scopes need to be updated. https://github.com/googleapis/google-auth-library-ruby
[17:38:03] [Butch]: has joined #RubyOnRails
[17:42:38] orbyt_: has joined #RubyOnRails
[17:47:26] Guest16678: has joined #RubyOnRails
[17:49:07] octos: has joined #RubyOnRails
[17:49:26] krawchyk: has joined #RubyOnRails
[18:00:28] jobewan: has joined #RubyOnRails
[18:04:18] hellekin: has joined #RubyOnRails
[18:04:22] valadares: has joined #RubyOnRails
[18:05:13] orbyt_: has joined #RubyOnRails
[18:15:19] cagmz: has joined #RubyOnRails
[18:16:40] cagmz: if I have a `datetime` column on a rails model, does it matter if I set it using a `Time` object or a `Date` object?
[18:16:54] blackmesa: has joined #RubyOnRails
[18:21:27] valadares: has joined #RubyOnRails
[18:27:17] v01d4lph4: has joined #RubyOnRails
[18:34:40] aldodelgado: You should be able to use time object
[18:38:41] v01d4lph4: has joined #RubyOnRails
[18:41:05] reber: has joined #RubyOnRails
[18:47:53] NeXTSUN: has joined #RubyOnRails
[18:49:51] guyzmo: cagmz - actually, when in doubt, you /should/ use the Time object
[18:50:05] guyzmo: (rubocop taught me that ;-) )
[18:51:04] guyzmo: Time is using bindings from the systems, so it's much more efficient, DateTime is more complex and a full ruby implementation. It's useful only for some corner cases (which I don't remember) you're unlikely to need it for
[18:53:44] gambl0r3: has joined #RubyOnRails
[19:00:08] andywww: has joined #RubyOnRails
[19:00:24] andywww: can someone give me a hand with preloading please
[19:00:28] andywww: https://hastebin.com/olezenijux.sql
[19:01:19] andywww: when calling wiki.json it won’t acknowledge the preloading on the index action
[19:01:26] andywww: am i doing something wrong?
[19:07:21] dviola: has joined #RubyOnRails
[19:12:35] Technodrome: has joined #RubyOnRails
[19:15:40] andywww: hmm, found it, preload(:user) should have been preload!(:user)
[19:17:24] gambl0r3: has joined #RubyOnRails
[19:24:18] v01d4lph4: has joined #RubyOnRails
[19:43:55] blackmesa: has joined #RubyOnRails
[19:47:49] andywww: has left #RubyOnRails: ()
[19:50:33] _aeris_: has joined #RubyOnRails
[19:50:59] jobewan: has joined #RubyOnRails
[20:04:15] alan_w: has joined #RubyOnRails
[20:08:41] agent_white: has joined #RubyOnRails
[20:16:11] SteenJobs: has joined #RubyOnRails
[20:19:32] octos: has joined #RubyOnRails
[20:28:25] kapil____: has joined #RubyOnRails
[20:30:00] za1b1tsu: has joined #RubyOnRails
[20:48:58] lxsameer: has joined #RubyOnRails
[20:56:18] NeXTSUN: has joined #RubyOnRails
[21:04:12] orbyt_: has joined #RubyOnRails
[21:06:41] SteenJobs: has joined #RubyOnRails
[21:09:50] newton: has joined #RubyOnRails
[21:11:33] newton: is there something different from `as` where I can tell a nested resources to generate routes like "new_y_path" rather than "new_x_y_path"?
[21:20:03] cnsvc: has joined #RubyOnRails
[21:22:13] tdy: has joined #RubyOnRails
[21:28:32] SteenJobs: has joined #RubyOnRails
[21:44:01] hive-mind: has joined #RubyOnRails
[21:50:28] NeXTSUN: has joined #RubyOnRails
[21:55:35] kvda: has joined #RubyOnRails
[22:12:58] tdy: has joined #RubyOnRails
[22:28:40] blackmesa: has joined #RubyOnRails
[22:31:26] kvda: has joined #RubyOnRails
[22:39:24] quazimodo: has joined #RubyOnRails
[22:40:23] istrasci: has joined #RubyOnRails
[22:41:21] istrasci: If I have scope :important and :active, I can chain them to get the intersection of them (MyModel.important.active). How do I get the union of them?
[22:42:08] istrasci: Do I just use 'or'?? MyModel.important.or(MyModel.active) ?
[23:04:45] work_: has joined #RubyOnRails
[23:11:44] Doddlin: has joined #RubyOnRails
[23:11:53] Technodrome: has joined #RubyOnRails
[23:14:28] barhum2013: has joined #RubyOnRails
[23:21:49] bruul: has joined #RubyOnRails