#RubyOnRails - 24 January 2018
« Back 1 day Forward 1 day »
[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: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.
[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?
[11:25:20] dionysus69: that is more for saving global keys that you would otherwise save in env vars
[11:25:43] dionysus69: I meant like, it's obviously a bad practice to create a column for n confirmable tasks
[11:26:34] dionysus69: user wants to delete something for example, and needs to confirm with email before it happens
[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: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: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: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: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:59] xhoy: depence on where you store your actions, and if you send the user as part of the "clickme url"
[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:37:07] xhoy: ii would then send the use an url with an url, with a token, an userid or something
[11:37:45] xhoy: and then they click it, it does something like, DelayedActions.find_by(token: token)
[11:38:43] dionysus69: thanks xhoy :) will get to it :) ye I always use strong params, if that's what you mean
[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: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: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
[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: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
[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: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:52:08] thesubr00t: How to combine two has_many associations into one AR relation? https://gist.github.com/thesubr00t/bff005b56d75bd2832e3e16e4fbc4e71
[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:57:34] lupine: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/group_hierarchy.rb
[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:44:30] rubycoder38: importing everything all the time while preventing duplicates would be bad for performance, I wonder if there's another way
[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?
[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:46:15] _aiguuu_: Is setting `I18n.locale = locale` thread safe? Or does this mess with subsequent requests?