« Back to channel list

#RubyOnRails - 24 January 2018

« Back 1 day Forward 1 day »
[00:05:02] jottr_: has joined #RubyOnRails
[00:08:20] kapil___: has joined #RubyOnRails
[00:10:57] alfiemax: has joined #RubyOnRails
[00:15:58] crankharder: has joined #RubyOnRails
[00:19:40] mochiyoda: has joined #RubyOnRails
[00:24:43] quazimodo: has joined #RubyOnRails
[00:29:19] bronson: has joined #RubyOnRails
[00:30:32] alfiemax: has joined #RubyOnRails
[00:49:34] workmad3: has joined #RubyOnRails
[00:56:25] fumk: has joined #RubyOnRails
[01:18:48] Dimik: has joined #RubyOnRails
[01:21:02] Saukk: has joined #RubyOnRails
[01:30:09] bronson: has joined #RubyOnRails
[01:33:44] Axsuul: has joined #RubyOnRails
[01:36:51] dustinm`: has joined #RubyOnRails
[01:48:11] xuyuheng: has joined #RubyOnRails
[02:00:29] crankharder: has joined #RubyOnRails
[02:02:10] alfiemax: has joined #RubyOnRails
[02:09:06] dblessing: has joined #RubyOnRails
[02:35:01] crankharder: has joined #RubyOnRails
[02:48:44] Caerus: has joined #RubyOnRails
[02:50:24] workmad3: has joined #RubyOnRails
[02:55:41] crankharder: has joined #RubyOnRails
[02:59:00] Saukk: has joined #RubyOnRails
[03:04:22] tipyn: has joined #RubyOnRails
[03:09:59] orbyt_: has joined #RubyOnRails
[03:19:12] darkhanb: has joined #RubyOnRails
[03:31:22] bronson: has joined #RubyOnRails
[03:39:38] tipyn: has joined #RubyOnRails
[03:41:38] sameerynho: has joined #RubyOnRails
[03:43:57] orbyt_: has joined #RubyOnRails
[03:54:43] atrius: has joined #RubyOnRails
[03:59:20] kies: has joined #RubyOnRails
[04:00:03] alfiemax: has joined #RubyOnRails
[04:32:43] xuyuheng: has joined #RubyOnRails
[04:59:01] alfiemax: has joined #RubyOnRails
[05:06:09] Tempesta: has joined #RubyOnRails
[05:08:54] thejamespinto: has joined #RubyOnRails
[05:11:38] iamarun: has joined #RubyOnRails
[05:16:44] nso95: has joined #RubyOnRails
[05:24:34] alfiemax: has joined #RubyOnRails
[05:27:17] atrius: has joined #RubyOnRails
[05:43:47] xuyuheng: has joined #RubyOnRails
[06:52:03] workmad3: has joined #RubyOnRails
[06:57:38] darkhanb: has joined #RubyOnRails
[07:05:32] DrYockel: has joined #RubyOnRails
[07:06:58] trautwein: has joined #RubyOnRails
[07:08:49] ur5us: has joined #RubyOnRails
[07:20:52] conta: has joined #RubyOnRails
[07:23:25] za1b1tsu: has joined #RubyOnRails
[07:25:24] mtkd: has joined #RubyOnRails
[07:28:39] trautwein: has joined #RubyOnRails
[07:33:08] bronson: has joined #RubyOnRails
[07:50:48] arBmind: has joined #RubyOnRails
[08:07:15] Puffball: has joined #RubyOnRails
[08:09:15] dionysus69: has joined #RubyOnRails
[08:20:03] justicef_: has joined #RubyOnRails
[08:20:17] Axsuul: has joined #RubyOnRails
[08:22:27] xuyuheng: has joined #RubyOnRails
[08:28:13] Dimik: has joined #RubyOnRails
[08:28:58] za1b1tsu: So I have 2 attributes min, max. Anyway I can have a standard validation that check either both are nil, or none are nil?
[08:31:25] dogweather: has joined #RubyOnRails
[08:33:34] defsdoor: has joined #RubyOnRails
[08:40:53] za1b1tsu: A rating belongs_to subjects. I'm doing validations for ratings according to some subject.types. But if I create a rating with a subject that does not exists, I get RecordNotFound.
[08:41:08] za1b1tsu: Anyway I can validate first that subject exists?
[08:43:17] sandstrom: has joined #RubyOnRails
[08:43:47] srinidhi: has joined #RubyOnRails
[08:48:01] dionysus69: has joined #RubyOnRails
[08:50:10] apeiros_: has joined #RubyOnRails
[08:52:54] workmad3: has joined #RubyOnRails
[08:53:07] mr-spoon: has joined #RubyOnRails
[08:54:22] Axsuul: has joined #RubyOnRails
[09:04:02] tipyn: has joined #RubyOnRails
[09:08:59] TvL2386: has joined #RubyOnRails
[09:12:03] _aeris_: has joined #RubyOnRails
[09:13:13] thejamespinto: has joined #RubyOnRails
[09:14:20] zigzig: has joined #RubyOnRails
[09:22:25] marr: has joined #RubyOnRails
[09:30:57] mtkd: has joined #RubyOnRails
[09:37:56] sameerynho: has joined #RubyOnRails
[09:46:57] gregf_: has joined #RubyOnRails
[09:48:20] bronson: has joined #RubyOnRails
[10:04:25] GodFather: has joined #RubyOnRails
[10:05:09] tipyn: has joined #RubyOnRails
[10:24:36] Cavallari: has joined #RubyOnRails
[10:34:05] za1b1tsu: has joined #RubyOnRails
[10:36:13] xuyuheng: has joined #RubyOnRails
[10:46:55] Torrone: has joined #RubyOnRails
[10:48:17] Torrone: Hello, I have a question about rspec that I found hard to answer by googling: Is there a way to test that a model has a method and that the said method is implemented on the class and not in an included module?
[10:50:46] arBmind: has joined #RubyOnRails
[10:56:17] sandstrom: has joined #RubyOnRails
[11:08:54] tipyn: has joined #RubyOnRails
[11:23:14] dionysus69: what's a good practice for saving temporary tokens?
[11:23:29] xhoy: that is a good question
[11:23:41] dionysus69: like any random action would need email confirmation before it is finalized
[11:23:50] xhoy: rails 5.2 has an update for that iirc
[11:24:17] dionysus69: Ye I have heard something secret storage or something
[11:24:22] hfp_work: has joined #RubyOnRails
[11:24:35] xhoy: but i don't know if that is for your situation
[11:24:58] dionysus69: I dont think it is :D
[11:25:12] xhoy: ah then i have no clue :P
[11:25:20] dionysus69: that is more for saving global keys that you would otherwise save in env vars
[11:25:39] xhoy: why would you store a session key? doesn't rails do that for you?
[11:25:43] dionysus69: I meant like, it's obviously a bad practice to create a column for n confirmable tasks
[11:25:49] xhoy: (well i call it a session key, but its a token :))
[11:26:04] xhoy: it is a token for a remote session or something?
[11:26:18] dionysus69: no just to confirm some user action
[11:26:34] dionysus69: user wants to delete something for example, and needs to confirm with email before it happens
[11:26:36] xhoy: look at how device does it
[11:26:46] dionysus69: devise uses array column I think
[11:26:47] xhoy: you can reqequest your password
[11:26:54] xhoy: it then sends you a hash
[11:27:00] xhoy: in a nice email etc etc
[11:27:34] xhoy: how long do they have to comfirm?
[11:27:39] xhoy: minutes? hours? days?
[11:28:25] xhoy: if its only temporary you could use something like redis/memcache to store it, this would make sure, if the server restarts everything is reset (some knid of security :))
[11:28:39] xhoy: and where do you store the action?
[11:28:49] xhoy: (delete $ record)
[11:29:50] xhoy: you could, just my .02€ create a table with object, action, sometoken, send $user email with $token2, and perform some kind of handshake with the two (password salt thing) to confirm it's the user
[11:29:52] mixnblend: has joined #RubyOnRails
[11:30:26] xhoy: you then never store the token you send an user, thus when the DB is *ever* stolen, they only have half of the key
[11:30:46] apeiros: has joined #RubyOnRails
[11:31:00] xhoy: maybe you can even use the devise salt/bcrypt thing and abuse it for this :)
[11:31:08] dionysus69: its not timed
[11:31:36] xhoy: you could just set a created_at in the action table and just crontab it every onece in a while and clear old stuff
[11:31:41] darkhanb: has joined #RubyOnRails
[11:31:57] dionysus69: and it's not for something super vital so no need for super security :D just wondering if I should an array column with hashes or something else
[11:32:17] dionysus69: then iterate through hashes and see compare tokens with various operations
[11:32:59] xhoy: depence on where you store your actions, and if you send the user as part of the "clickme url"
[11:33:42] dionysus69: SecureRandom.urlsafe_base64(nil, false) this would do
[11:34:21] dionysus69: just generates 22 long string
[11:34:59] dionysus69: but my question is, what's the best way to save it and then efficiently compare it. given that there will be lots of tokens for various confirmable tasks
[11:35:19] xhoy: a string with an index
[11:35:35] xhoy: since you will be only matching the full token and not parts of it
[11:35:48] dionysus69: string would hold only single string
[11:36:01] dionysus69: what about I have 2 tokens for 2 different actions?
[11:36:14] xhoy: two different rows
[11:36:28] xhoy: you would get a database with, object, action, user, hash
[11:36:29] dionysus69: you mean create a table for it I see
[11:36:42] dionysus69: I thought I would fit tokens in a user row
[11:36:43] xhoy: since your talking about many actions
[11:37:07] xhoy: ii would then send the use an url with an url, with a token, an userid or something
[11:37:17] xhoy: or action maybe or only token if you like
[11:37:19] dionysus69: ok ok actually, creating a model for it doesnt sound bad
[11:37:33] dionysus69: actually it's easier than handling single column array of hashes
[11:37:45] xhoy: and then they click it, it does something like, DelayedActions.find_by(token: token)
[11:37:52] xhoy: and re opening stuff
[11:37:58] xhoy: and forfils the action
[11:38:11] xhoy: BUT be carefull, to whitelist actions and objects
[11:38:27] xhoy: if you just do everything thats in the DB it could hurt you
[11:38:43] dionysus69: thanks xhoy :) will get to it :) ye I always use strong params, if that's what you mean
[11:38:45] xhoy: o the db woudl be class, object (or polymorphic: holder0
[11:39:10] xhoy: in this case if i would enter a row, user, 1, delete, <tokeN>
[11:39:20] xhoy: and then would lick my self generated link/token
[11:39:23] xhoy: i could delete the admin
[11:39:38] xhoy: so i would do something with
[11:40:06] xhoy: if [list with objects].includes?(user)
[11:40:12] xhoy: and something with actions
[11:49:00] bronson: has joined #RubyOnRails
[11:50:00] marr: has joined #RubyOnRails
[11:53:24] dionysus69: what about this https://gist.github.com/anonymous/596c93daa5f38a38b9254a568e02e5ba
[11:55:08] dionysus69: on validatable action, new token will be created and it would belong to the object with a token
[11:55:53] dionysus69: if both fk and token correct, then the action will proceed. I will pass fk and token in the email validation link's params
[11:56:35] dionysus69: xhoy: what? doesn't it make sense?
[11:59:04] dionysus69: why not, thought about it and it can't be cheated and it would confirm validity too, can't see the problem
[12:00:56] xhoy: https://gist.github.com/anonymous/bc4a79754c55f2fde7ac12df62951696
[12:01:52] dici: has joined #RubyOnRails
[12:03:38] dionysus69: that is too generic for my use case : )
[12:03:51] dionysus69: my validatable objects won't share similar methods anyway :)
[12:04:23] xhoy: well you can just whitelist a single class
[12:04:32] xhoy: if it works for éverything' it works for one thing
[12:04:41] xhoy: your current way looks really messy
[12:05:48] dionysus69: hmm ok see what I can do, need some walk and fresh air :D
[12:05:59] xhoy: https://gist.github.com/anonymous/ef3df27bb1d13639ae387fe0d1b2af97
[12:06:04] xhoy: this is beter one with controller :0
[12:06:11] alfiemax: has joined #RubyOnRails
[12:06:26] dionysus69: also one more thing
[12:06:28] xhoy: and you could do some feedback, messing, "it worked stuff"
[12:06:33] dionysus69: I will not guarantee the uniqueness of the token
[12:06:35] xhoy: messiging
[12:06:43] xhoy: that is what version 2 does
[12:06:49] dionysus69: that's why I wanted to make uniqueness using id + token
[12:07:21] xhoy: id of the object?
[12:08:38] tipyn: has joined #RubyOnRails
[12:08:48] xhoy: https://gist.github.com/xhoy/97ffb8113eb166f0d0f4728f2159914f
[12:08:56] xhoy: you can validate uniqness of 'holder'
[12:09:03] xhoy: in the model aswell
[12:09:51] xhoy: and i would do *some* validation for model, and action combo, just to be sure :)
[12:10:15] xhoy: and you don't want to validat uniqness of holder + key, since to users can do the same action on the same object
[12:10:34] xhoy: but that is up to you
[12:10:57] xhoy: rails is a beauty for this kind of stuff
[12:11:31] dionysus69: ok I ll take a rest and look at this once again a bit later
[12:13:14] aiguuu: has joined #RubyOnRails
[12:15:31] xhoy: (and except for some typo's this should basicly work :))
[12:15:40] thejamespinto: has joined #RubyOnRails
[12:15:48] mtkd: has joined #RubyOnRails
[12:29:02] DrYockel: has joined #RubyOnRails
[12:29:04] kapil___: has joined #RubyOnRails
[12:32:43] one_zero: has joined #RubyOnRails
[12:33:38] zigzig: has joined #RubyOnRails
[12:37:51] Ergo: has joined #RubyOnRails
[12:39:20] Arkentias: has joined #RubyOnRails
[12:54:34] workmad3: has joined #RubyOnRails
[13:04:01] alfiemax: has joined #RubyOnRails
[13:04:16] tipyn: has joined #RubyOnRails
[13:27:10] Ergo: has joined #RubyOnRails
[13:36:01] apparition: has joined #RubyOnRails
[13:45:36] xuyuheng: has joined #RubyOnRails
[13:50:07] bronson: has joined #RubyOnRails
[13:51:22] dblessing: has joined #RubyOnRails
[14:05:48] goldleader: has joined #RubyOnRails
[14:07:40] tcopeland: has joined #RubyOnRails
[14:10:34] tipyn: has joined #RubyOnRails
[14:15:14] Tempesta: has joined #RubyOnRails
[14:23:40] greengriminal: has joined #RubyOnRails
[14:26:40] dviola: has joined #RubyOnRails
[14:27:37] thejamespinto: has joined #RubyOnRails
[14:28:21] dionysus69: has joined #RubyOnRails
[14:34:50] tycoon177: morning! is there a way to modify the fetched columns from an includes in activerecord? i'm including together data from 5 different sources, which results in several hundred columns, of which i only need about 20. There are a maximum of 100 rows returned in each page, resulting in VERY slow loading times. The query, in development, is taking >5 seconds, for example
[14:40:01] tbuehlmann: when manually preloading an association you can alter the selected columns
[14:40:06] tbuehlmann: I don't know of any other way
[14:45:26] tycoon177: tbuehlmann: could you link me to an example? that sounds like what i want to do, but i have been unsuccessful in googling this
[14:45:54] tbuehlmann: https://gist.github.com/tbuehlmann/d747212e72da48ffc79d8bbe8dd478e1
[14:47:07] chavdardimitrov: has joined #RubyOnRails
[14:47:16] jobewan: has joined #RubyOnRails
[14:55:25] workmad3: has joined #RubyOnRails
[14:58:22] LightStalker: has joined #RubyOnRails
[15:06:10] moei: has joined #RubyOnRails
[15:10:07] hammer065: has joined #RubyOnRails
[15:16:17] tycoon177: tbuehlmann: ty
[15:18:54] cpruitt: has joined #RubyOnRails
[15:24:57] workmad3: has joined #RubyOnRails
[15:32:48] rubycoder38: has joined #RubyOnRails
[15:35:44] rubycoder38: hi, I have an API that returns an array of courses, I need to write a program that will listen for new courses and publish that information to another site, this is my API: https://api.eadbox.com/ my question is how do I check for new courses? is that something that needs to be specific to the API or is there something I can use? thanks in advance
[15:43:16] cpruitt: rubycoder38: Unless the API does something to notify you, you'll need your server to periodically check your endpoint to see if there is anything new. That could be a cron job running a rake task, or it could be using something like ActiveJob to schedule a repeating task, or something else. What you use is pretty much your preference, but you'll need to do the checking somehow.
[15:43:48] cpruitt: In other words, you will ask for new information, you won't really "listen" for updates.
[15:45:38] xuyuheng: has joined #RubyOnRails
[15:47:36] thesubr00t: has joined #RubyOnRails
[15:48:56] rubycoder38: right but it sounds like I'll need to store that data locally also, like in a database and have a field to store which courses I already published
[15:49:21] rubycoder38: to keep track of which I already published, I mean
[15:51:18] bronson: has joined #RubyOnRails
[15:52:08] thesubr00t: How to combine two has_many associations into one AR relation? https://gist.github.com/thesubr00t/bff005b56d75bd2832e3e16e4fbc4e71
[15:52:43] lupine: what combination operator would you like to use?
[15:52:56] lupine: presumably AND
[15:53:11] lupine: throw in a union
[15:53:21] aesthetikx: has joined #RubyOnRails
[15:54:17] thesubr00t: lupine, Union & uniq
[15:54:41] thesubr00t: Will that preserve the AR relation?
[15:54:49] LateralOctober: has joined #RubyOnRails
[15:54:50] lupine: there are ways to do so, ys
[15:55:17] lupine: the other approach would be a CTE to allow you to traverse the (very short) graph directly in SQL
[15:55:29] aesthetikx: by what mechanism are devise methods such as current_user available to view helpers? I have a presenter layer that I want to be able to access such methods as current_user within, for example.
[15:56:52] aesthetikx: i see they are using helper_method.
[15:57:07] thesubr00t: lupine, can you please comment out the gist?
[15:57:34] lupine: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/group_hierarchy.rb
[15:57:41] lupine: a worked example for you
[15:58:53] thesubr00t: lupine, thanks
[15:59:13] thejamespinto: has joined #RubyOnRails
[16:12:18] DrYockel: has joined #RubyOnRails
[16:17:18] choke: has joined #RubyOnRails
[16:19:52] mtkd: has joined #RubyOnRails
[16:26:33] mixnblend: has joined #RubyOnRails
[16:27:59] dblessing: has joined #RubyOnRails
[16:39:38] desperek: has joined #RubyOnRails
[16:43:55] uks: has joined #RubyOnRails
[16:45:02] Axsuul: has joined #RubyOnRails
[16:50:40] alfiemax_: has joined #RubyOnRails
[16:58:48] alfiemax: has joined #RubyOnRails
[17:05:17] apeiros_: has joined #RubyOnRails
[17:11:34] thejamespinto: has joined #RubyOnRails
[17:12:22] one_zero: has joined #RubyOnRails
[17:20:01] troys: has joined #RubyOnRails
[17:22:30] DrYockel: has joined #RubyOnRails
[17:25:07] darkhanb: has joined #RubyOnRails
[17:25:45] Axsuul: has joined #RubyOnRails
[17:29:10] orbyt_: has joined #RubyOnRails
[17:32:56] [Butch]: has joined #RubyOnRails
[17:40:26] s2013: has joined #RubyOnRails
[17:44:00] conta: has joined #RubyOnRails
[17:44:08] cpruitt: has joined #RubyOnRails
[17:45:29] marr: has joined #RubyOnRails
[17:46:28] workmad3: has joined #RubyOnRails
[17:52:23] bronson: has joined #RubyOnRails
[17:55:05] Dimik: has joined #RubyOnRails
[18:16:07] rrichardsr3: has joined #RubyOnRails
[18:26:33] cstls: has joined #RubyOnRails
[18:35:17] NoGodDamnIdea: has joined #RubyOnRails
[18:39:29] rubycoder38: has joined #RubyOnRails
[18:41:17] rubycoder38: so I have this API but I'm not sure how to ask the api for "new" information, do I just keep importing all the data while preventing duplicates? I can't find another way, by reading the documentation I can request data by number of pages only
[18:41:23] rubycoder38: this is my api: https://api.eadbox.com/
[18:42:16] rubycoder38: specifically I'm looking for /courses
[18:42:17] apeiros: has joined #RubyOnRails
[18:44:30] rubycoder38: importing everything all the time while preventing duplicates would be bad for performance, I wonder if there's another way
[18:46:22] apeiros__: has joined #RubyOnRails
[19:04:03] KeyJoo: has joined #RubyOnRails
[19:04:57] rrichardsr3: has joined #RubyOnRails
[19:05:22] tipyn: has joined #RubyOnRails
[19:06:32] jottr_: has joined #RubyOnRails
[19:21:39] crova: has joined #RubyOnRails
[19:22:32] crova: Greetings folks, how is it going? What would be the best approach (scopes? gems?) to search a model for multiple attributes using a multi-select list on a form?
[19:24:19] DrYockel: has joined #RubyOnRails
[19:47:18] workmad3: has joined #RubyOnRails
[19:53:02] bronson: has joined #RubyOnRails
[19:55:05] greengriminal: has joined #RubyOnRails
[20:03:25] greengriminal: has joined #RubyOnRails
[20:05:08] greengriminal: has joined #RubyOnRails
[20:05:12] tipyn: has joined #RubyOnRails
[20:09:51] Andr3as: a Model.where(foo: params[:foo]) would be too simple?
[20:30:19] s2013: has joined #RubyOnRails
[20:37:39] crova: Andr3as, where uses AND as clause, so when I pass multiple parameters it halts. I need to pass OR here
[20:41:44] baweaver_away: crova: where(a: 1).or.where(b: 2)
[20:44:47] Andr3as: crova: Model.where(query.where_values.map(&:to_sql).join(" OR "))
[20:45:05] Andr3as: https://coderwall.com/p/dgv7ag/or-queries-with-arrays-as-arguments-in-rails-4
[20:45:48] greengriminal: has joined #RubyOnRails
[20:45:56] _aiguuu_: has joined #RubyOnRails
[20:46:15] _aiguuu_: Is setting `I18n.locale = locale` thread safe? Or does this mess with subsequent requests?
[20:50:59] sameerynho: has joined #RubyOnRails
[20:54:10] bronson: has joined #RubyOnRails
[20:57:37] s2013: has joined #RubyOnRails
[21:00:43] rrichardsr3: has joined #RubyOnRails
[21:01:29] camfowler: has joined #RubyOnRails
[21:10:07] tipyn: has joined #RubyOnRails
[21:13:54] Puffball: has joined #RubyOnRails
[21:19:01] Radar: GOOD MORNING
[21:19:13] Radar: _aiguuu_: as of recent I18n versions it is threadsafe.
[21:24:30] TViernion: has joined #RubyOnRails
[21:27:41] jottr: has joined #RubyOnRails
[21:32:07] camfowler: has joined #RubyOnRails
[21:36:02] s2013: has joined #RubyOnRails
[21:48:10] workmad3: has joined #RubyOnRails
[21:54:18] sandstrom: has joined #RubyOnRails
[21:55:06] bronson: has joined #RubyOnRails
[21:55:36] Puffball: has joined #RubyOnRails
[21:57:02] zleap: has joined #RubyOnRails
[22:01:18] crova: Andr3as, thanks for the info, you too baweaver
[22:08:13] tipyn: has joined #RubyOnRails
[22:09:05] quazimodo: has joined #RubyOnRails
[22:19:58] choke: has joined #RubyOnRails
[22:22:02] blackmesa: has joined #RubyOnRails
[22:24:34] mtkd: has joined #RubyOnRails
[22:30:29] arBmind: has joined #RubyOnRails
[22:37:05] NoGodDamnIdea: has joined #RubyOnRails
[22:46:44] mlt-: has joined #RubyOnRails
[22:47:53] orbyt_: has joined #RubyOnRails
[22:49:45] alfiemax: has joined #RubyOnRails
[22:50:40] jottr_: has joined #RubyOnRails
[22:56:07] bronson: has joined #RubyOnRails
[23:04:31] tipyn: has joined #RubyOnRails
[23:15:49] TinkerTyper: has joined #RubyOnRails
[23:15:56] sameerynho: has joined #RubyOnRails
[23:16:54] tipyn: has joined #RubyOnRails
[23:38:27] chavdardimitrov: has joined #RubyOnRails
[23:45:42] alfiemax: has joined #RubyOnRails
[23:47:17] chavdardimitrov: has joined #RubyOnRails
[23:48:54] workmad3: has joined #RubyOnRails
[23:56:38] bronson: has joined #RubyOnRails