« Back to channel list

#RubyOnRails - 17 May 2017

« Back 1 day Forward 1 day »
[00:03:29] carlosd: has joined #RubyOnRails
[00:04:45] User458764: has joined #RubyOnRails
[00:04:45] waseem_: has joined #RubyOnRails
[00:15:43] _doomy: has joined #RubyOnRails
[00:16:26] _doomy: Hi all, is this an appropriate place to discuss questions relating to Rails 5.1?
[00:20:02] ascarter: has joined #RubyOnRails
[00:21:51] _doomy: I've been having trouble with yarn after upgrading from 5.0 to 5.1 - is there any documentation on how to do this properly? I've only found guides that show how to start new projects with the "--yarn" option, however when I include `node_modules` in my assets I still recieve errors that the resource does not exist.
[00:35:19] mrgreenfur: has left #RubyOnRails: ()
[00:36:58] brendan-: has joined #RubyOnRails
[00:38:28] patarr: has joined #RubyOnRails
[00:52:13] apparition: has joined #RubyOnRails
[00:53:06] patarr: has joined #RubyOnRails
[01:06:54] patarr: has joined #RubyOnRails
[01:14:02] mrgreenfur: has joined #RubyOnRails
[01:14:36] bruno-: has joined #RubyOnRails
[01:27:37] quazimodo: has joined #RubyOnRails
[01:28:25] sevenseacat: has joined #RubyOnRails
[01:29:22] patarr: has joined #RubyOnRails
[01:35:28] quirkycoders: has joined #RubyOnRails
[01:44:46] mrgreenfur: has joined #RubyOnRails
[01:49:08] patarr: has joined #RubyOnRails
[01:50:07] ascarter: has joined #RubyOnRails
[01:57:16] quazimodo: has joined #RubyOnRails
[02:03:08] bratsche: has joined #RubyOnRails
[02:06:46] ascarter_: has joined #RubyOnRails
[02:07:12] tomasm-: has joined #RubyOnRails
[02:07:20] Jameser: has joined #RubyOnRails
[02:10:20] HoierM: has joined #RubyOnRails
[02:11:32] quirkycoders: has joined #RubyOnRails
[02:11:52] ascarter_: has joined #RubyOnRails
[02:14:54] irishfromua: has joined #RubyOnRails
[02:15:52] tomasm-: what are some easy rails deployment/hosting solutions that arent expensive for commercial use? heroku seems like it jumps from $7/mo to $50/mo once an app starts getting used at any level
[02:20:56] ascarter: has joined #RubyOnRails
[02:22:44] ascarter: has joined #RubyOnRails
[02:25:04] sevenseacat: thats not expensive for commercial use
[02:25:19] sevenseacat: you do get what you pay for.
[02:27:19] dblessing: has joined #RubyOnRails
[02:28:54] duderonomy: has joined #RubyOnRails
[02:32:31] quazimodo: has joined #RubyOnRails
[02:50:17] itarato: has joined #RubyOnRails
[02:58:59] bobbobbins: has joined #RubyOnRails
[03:00:27] Jameser: has joined #RubyOnRails
[03:00:43] ascarter: has joined #RubyOnRails
[03:04:58] doomy1: has joined #RubyOnRails
[03:08:53] _doomy: has joined #RubyOnRails
[03:13:04] doomy1: has joined #RubyOnRails
[03:14:27] ascarter: has joined #RubyOnRails
[03:18:59] duderonomy: has joined #RubyOnRails
[03:23:35] quirkycoders: has joined #RubyOnRails
[03:41:48] bobbobbins: has joined #RubyOnRails
[03:49:03] jane_booty_doe: has joined #RubyOnRails
[03:51:01] harfangk: has joined #RubyOnRails
[03:58:39] hndk: has joined #RubyOnRails
[03:59:37] quirkycoders: has joined #RubyOnRails
[04:19:18] ger0: has joined #RubyOnRails
[04:31:18] ascarter_: has joined #RubyOnRails
[04:35:28] wethu: has joined #RubyOnRails
[04:36:06] quirkycoders: has joined #RubyOnRails
[04:40:13] uks: has joined #RubyOnRails
[04:45:40] cagomez: has joined #RubyOnRails
[04:49:54] JDeen: Hi... how can I use a non AR object for a param in action mailer. i believe there should be an serialize / deserialize process involved?
[04:50:11] JDeen: My partiular use is for an form object
[04:50:34] sevenseacat: got an example of what you want to do?
[04:51:25] JDeen: let me write up a gist, 1 min
[04:56:18] JDeen: sevenseacat: I was trying to do some thing like this: https://gist.github.com/ziyan-junaideen/3ee46d4bae168a4390b4d55d2f30984f
[04:56:27] JDeen: it says unsupported
[04:57:06] JDeen: unsupported argument type
[04:57:18] sevenseacat: right, so the problem is coming from activejob because you're calling deliver_later
[04:57:49] JDeen: so if i use deliver now, it might be fine.. yah makes sense...
[04:58:28] sevenseacat: it will be fine, yes - I don't know what you're using fot background job queueing but typically its recommended to use primitives and simple literals as params for them
[04:58:45] sevenseacat: though you could always serialize/deserialize yourself, but that would likely be error-prone
[04:59:23] JDeen: sevenseacat: yah, some years back i wrote to serialize and desearialize by my self and some tiems it got things wrong. thats why i was wondering if rails had a way to do it
[05:00:04] JDeen: i think i can get the arguments to kind of json and send
[05:00:10] sevenseacat: you could use marshalling but I wouldn't recommend it
[05:02:34] dminuoso: !goodmorning
[05:02:34] helpa: おはよう ございます
[05:03:07] dminuoso: https://gist.github.com/dminuoso/2ca84db41b85b78ee13efe528c387647 << No matter what I do, carrierwave is not storing any file in :last_changes, am I making some obvious (or less obvious) mistake?
[05:03:57] ascarter: has joined #RubyOnRails
[05:05:59] dionysus69: has joined #RubyOnRails
[05:08:08] Radar: dminuoso: no idea
[05:08:11] Radar: Seems like it should work
[05:08:45] sevenseacat: what do the logs say when you call ConstructionBulletin.make! ?
[05:09:39] patarr: has joined #RubyOnRails
[05:10:58] Radar: What does the object look like right before the save?
[05:11:18] dminuoso: sevenseacat: Beyond some transaction comments just SQL (0.2ms) INSERT INTO "construction_bulletins" ("created_at", "updated_at") VALUES ($1, $2) RETURNING "id" [["created_at", 2017-05-16 16:12:27 UTC], ["updated_at", 2017-05-16 16:12:27 UTC]]
[05:11:45] quirkycoders: has joined #RubyOnRails
[05:15:20] dminuoso: Radar: That's the thing. inspect says that last_changes is nil, but object.last_changes actually gives me the uploader containing the file.
[05:15:22] Technodrome: has joined #RubyOnRails
[05:15:31] dminuoso: But if I do obj.reload it's gone of course.
[05:16:00] Radar: dminuoso: not something like an attr_reader/writer defined for the field, overriding what carrierwave provides?
[05:16:00] sevenseacat: that sentence was confusing.
[05:17:07] dminuoso: sevenseacat: Mmm, let me rephrase in a moment. Gotta leave the train be back in a few minutes.
[05:35:39] dminuoso: Radar, sevenseacat: https://gist.github.com/dminuoso/79a7947b4751425a37a450670fc56f93
[05:38:15] dminuoso: About the only weird thing there is that it seems like the tempfile is never copied
[05:38:56] dminuoso: I mean while the uploader is not empty, its path is pointing towards a tmp file
[05:56:56] srinidhi: has joined #RubyOnRails
[06:05:04] ascarter: has joined #RubyOnRails
[06:16:04] bobbobbi_: has joined #RubyOnRails
[06:20:36] conta: has joined #RubyOnRails
[06:23:34] dionysus69: has joined #RubyOnRails
[06:23:49] quirkycoders: has joined #RubyOnRails
[06:25:09] Ergo: has joined #RubyOnRails
[06:30:27] itsgokul: has joined #RubyOnRails
[06:30:56] itsgokul: noob help how can i encrypt md5 and send userid through url
[06:34:39] tbuehlmann: itsgokul: md5 is a hashing algorithm. what's you usecase?
[06:35:16] itsgokul: i want to send userid from rails site to a php site through url encrypted
[06:36:27] tbuehlmann: as in: redirect the user to the php page?
[06:38:56] tbuehlmann: what is this about? why does the php page needs the user id?
[06:39:03] tbuehlmann: you have several options here, that's why I'm asking
[06:40:53] itsgokul: this php site has a copy of user table so i will take the userid join some other tables and create a session in php site
[06:41:26] DrYockel: has joined #RubyOnRails
[06:42:28] tbuehlmann: okay, and the user is not supposed to see/know the id?
[06:44:11] tbuehlmann: you could use encrypted JWT for that. that way both apps would need to share a secret in order to access the token
[06:44:52] tbuehlmann: you could also come up with your own solution, like encrypting a string as you like (you will need a shared secret with this, too)
[06:45:29] tbuehlmann: if it fits, some kind of SSO could work too, but maybe that's too much
[06:46:23] Technodrome: has joined #RubyOnRails
[06:55:35] quazimodo: has joined #RubyOnRails
[06:59:50] quirkycoders: has joined #RubyOnRails
[07:01:31] cagomez: has joined #RubyOnRails
[07:02:53] conta: has joined #RubyOnRails
[07:10:28] patarr: has joined #RubyOnRails
[07:17:29] arBmind: has joined #RubyOnRails
[07:25:33] uksio: has joined #RubyOnRails
[07:36:15] quirkycoders: has joined #RubyOnRails
[07:36:57] mikecmpbll: has joined #RubyOnRails
[07:41:51] awille: has joined #RubyOnRails
[07:51:29] bobbobbins: has joined #RubyOnRails
[07:51:40] rgr: has joined #RubyOnRails
[07:57:50] blackmesa: has joined #RubyOnRails
[07:59:08] mikecmpbll: has joined #RubyOnRails
[08:10:00] ur5us: has joined #RubyOnRails
[08:11:08] lipoqil: has joined #RubyOnRails
[08:11:20] User458764: has joined #RubyOnRails
[08:11:54] quirkycoders: has joined #RubyOnRails
[08:21:53] mdw: has joined #RubyOnRails
[08:22:19] Jameser: has joined #RubyOnRails
[08:23:19] ferr: has joined #RubyOnRails
[08:29:42] marr: has joined #RubyOnRails
[08:31:29] harfangk: has joined #RubyOnRails
[08:36:51] srinidhi: has joined #RubyOnRails
[08:37:09] harfangk: has joined #RubyOnRails
[08:40:28] lxsameer: has joined #RubyOnRails
[08:45:05] Pumukel: has joined #RubyOnRails
[08:48:18] blackmesa: has joined #RubyOnRails
[09:01:30] xall: has joined #RubyOnRails
[09:02:22] dminuoso: sevenseacat, Radar: Turns out defining a method :send in your model is not a smart thing to do.
[09:02:38] xall: has joined #RubyOnRails
[09:03:04] sevenseacat: funny what happens when you dont show all of the code :P
[09:03:20] dminuoso: sevenseacat: I did!
[09:03:23] dminuoso: My last snipped contained it.
[09:03:37] dminuoso: My initial was just stupid and silly like that.
[09:03:37] sevenseacat: huh, so it does.
[09:03:48] dminuoso: sevenseacat: Interestingly neither of you noticed either.
[09:04:00] loechel: has joined #RubyOnRails
[09:04:13] sevenseacat: I didn't check it, to be honest.
[09:04:32] dminuoso: No sweat. My mistake was not building a testcase.
[09:04:44] dminuoso: Which would have included stripping unnecessary stubs.
[09:05:21] mahloun: has joined #RubyOnRails
[09:10:53] xall_: has joined #RubyOnRails
[09:10:58] tbuehlmann: dminuoso: I assume it's not your code that screws up with #send, which code does that?
[09:11:17] patarr: has joined #RubyOnRails
[09:12:29] dminuoso: tbuehlmann: I have no idea. But it's pretty obvious that fucking around with #send in the realm of ActiveRecord is an inherently bad idea.
[09:12:42] tbuehlmann: I'd consider that a bug
[09:13:14] tbuehlmann: #send is meant to be used in ruby. I might be wrong, but I haven't read a statement about that in rails
[09:13:22] sevenseacat: meant to be called, not defined
[09:13:39] tbuehlmann: "used" as in define
[09:13:52] tbuehlmann: and I know, unpopular opinion, we just had this the other here..
[09:13:53] dminuoso: From that perspective Ruby should actually prevent me from defining it because I cant even conceive a reason why it would be an advantage
[09:14:06] tbuehlmann: dminuoso: it does warn you for __send__
[09:14:19] tbuehlmann: which is what one should use (after public_send)
[09:14:31] dminuoso: I just brutally .send all the things.
[09:14:49] dminuoso: And always tell people what you just did :P
[09:15:16] tbuehlmann: I prefer #public_send over #__send__ over #send
[09:16:06] tbuehlmann: but fryguy pointed out correctly that people don't care about #__send__ and just use #send
[09:16:12] dminuoso: Whats the difference?
[09:16:16] dminuoso: Or is it just exactly that?
[09:16:19] dminuoso: That __send__ warns?
[09:16:27] dminuoso: (Well overriding)
[09:16:40] dminuoso: This smells an awful lot like Pythonish
[09:16:49] tbuehlmann: I don't know about the implementation, yes, #__send__ warns, #send does not
[09:17:17] dminuoso: tbuehlmann: But fair enough looking at things Im starting to agree with you. A library should use __send__ especially if it uses it on objects of a class it doesnt own
[09:17:26] dminuoso: So its a bug
[09:17:26] cagomez: has joined #RubyOnRails
[09:17:48] tbuehlmann: "objects of a class it doesn't own" is a good point, yep
[09:21:47] shotbug: has joined #RubyOnRails
[09:22:50] arBmind: has joined #RubyOnRails
[09:23:59] quirkycoders: has joined #RubyOnRails
[09:27:11] shotbug: has joined #RubyOnRails
[09:29:03] mahloun: has joined #RubyOnRails
[09:31:10] Jameser: has joined #RubyOnRails
[09:33:32] xall: has joined #RubyOnRails
[09:52:32] itarato: has joined #RubyOnRails
[09:57:16] xall_: has joined #RubyOnRails
[10:14:38] xall: has joined #RubyOnRails
[10:17:14] webdestroya: has joined #RubyOnRails
[10:18:39] xall: has joined #RubyOnRails
[10:26:40] patarr: has joined #RubyOnRails
[10:27:01] Technodrome: has joined #RubyOnRails
[10:36:57] itarato: has joined #RubyOnRails
[10:37:22] clyfe: has joined #RubyOnRails
[10:37:57] clyfe: has left #RubyOnRails: ()
[10:41:21] xall_: has joined #RubyOnRails
[10:46:16] shilon: has joined #RubyOnRails
[10:46:34] shilon: Hello my dear developer friends.
[10:49:24] shilon: I’m using devise to registrations to create users, and in this registrations users must validate first_name and last_name. Meanwhile I’m also using devise_invitable, but when inviting a user I just want to have present the email. What happens is that both forms are :create actions for the same model “User”… Is there a way to only do “validate: first_name, only: sign_up”?????
[10:50:06] xall: has joined #RubyOnRails
[10:50:09] shilon: I’ve tried unless: :invited_to_sign_up? but it doesn’t work :/
[10:52:09] mrbubbles: Perhaps a silly question - ActiveRecord is obviously great for record-based stuff (posts, invoices, etc) but what's the best away to store key-value pairs for things like application config? Obviously user config could just be stored in it's own table (or the user table) whereas application config is more of a singleton perhaps?
[10:54:56] xall: has joined #RubyOnRails
[10:56:39] mrbubbles: Ah I guess just create a Settings table with key and value columns, then just cache the whole lot on application load
[11:00:03] stamina: has joined #RubyOnRails
[11:03:58] xall: has joined #RubyOnRails
[11:06:39] quazimodo: What's the general solution for when your front end has to hit an API for some data, which is then appended to a form and sent to the back end to use
[11:06:51] quazimodo: in this case, a delivery quote, reference and expiry
[11:07:05] mrbubbles: quazimodo So I did this with an account migration thing recently
[11:07:07] quazimodo: eg user could send back bad data/not connect to the service api/timeout
[11:07:22] quazimodo: the UX can get really shitty
[11:07:48] matthewd: quazimodo: You don't.
[11:08:05] mrbubbles: I went for: you enter your old username and password, it verifies that you are who you say you are, then returns a random GUID which is stored in a hidden field in a form. Then when you have completed the migration to the new account format it uses that GUID to lookup the account and updates it with the new data
[11:08:34] matthewd: Either the frontend talks to your backend (which in turn talks to the API), or the backend independently makes the same request to the API
[11:08:54] mrbubbles: Oh wait I think I might have misunderstood the question :)
[11:11:18] xall: has joined #RubyOnRails
[11:11:55] quazimodo: matthewd: fair call, i thought so already and built that
[11:12:34] quazimodo: in this case user looks at product, no db record has been made. So i'd be storing the GUID of the quote against the product id on the user session?
[11:14:40] User458764: has joined #RubyOnRails
[11:15:13] User458764: has joined #RubyOnRails
[11:17:40] quazimodo: what's worse is these quotes expire, but the ordering process in this app can take a few days (lots of customizing back and forth)
[11:18:08] quazimodo: so i need to update that quote... at certain times
[11:20:22] Ove_: has joined #RubyOnRails
[11:23:03] shilon: has joined #RubyOnRails
[11:23:52] shilon: has joined #RubyOnRails
[11:24:40] shilon: has joined #RubyOnRails
[11:25:29] shilon: has joined #RubyOnRails
[11:26:13] Ove_: matthewd: Found the issue, or so I think.
[11:26:17] shilon: has joined #RubyOnRails
[11:26:56] Ove_: They (the devs) are running multiple applications (shared code base, but running different tasks) under the same application in newrelic.
[11:27:05] shilon: has joined #RubyOnRails
[11:27:51] shilon: has joined #RubyOnRails
[11:28:46] shilon: has joined #RubyOnRails
[11:30:57] Ove_: Yup, that was it.
[11:33:33] cagomez: has joined #RubyOnRails
[11:35:08] xall: has joined #RubyOnRails
[11:36:19] User458764: has joined #RubyOnRails
[11:39:32] fmcgeough: has joined #RubyOnRails
[11:43:54] rwsq1: has joined #RubyOnRails
[11:47:43] rwsq1: Hi guys. I'm making a service dashboard page with items (tables, graphs) that need to refresh every so often. I (possibly mistakenly) thought that turbolinks might be good for this kind of thing, however it seems that the only option there is to reload the entire page or specify some items to never change. When turbolinks refreshes the page it alters the viewport and some charts seem to resize before going back to how they were
[11:47:43] rwsq1: . Should I just abandon this idea and write some API calls that get spoken to by javascript instead?
[11:48:22] mrbubbles: rwsq1 yes I'd say that if you're doing periodic updating then api calls are definitely the best way
[11:48:34] w0rd-driven: has joined #RubyOnRails
[11:48:44] mrbubbles: I mean, someone might leave the dashboard open on their machine and you want it to update in realtime, rather than when they reload the page, no?
[11:49:21] rwsq1: well I've been triggering a turbolinks visit every few seconds
[11:49:30] rwsq1: but that's the idea, it just sits there and updates
[11:49:34] xall_: has joined #RubyOnRails
[11:49:52] ascarter: has joined #RubyOnRails
[11:50:00] rwsq1: it seems turbolinks is surprisingly near to being perfect, but I'd like to be able to trigger only particular elements to be refreshed, and that's not possible
[11:50:39] itarato: has joined #RubyOnRails
[11:51:32] rwsq1: mrbubbles, it looks like pjax might be what I need, but that seems much more complicated
[11:51:44] ascarter: has joined #RubyOnRails
[11:52:02] rwsq1: (and possibly too old to be useful)
[11:55:10] xall: has joined #RubyOnRails
[11:56:14] ferr: has joined #RubyOnRails
[11:57:18] quazimodo: has joined #RubyOnRails
[12:02:38] bobbobbins: has joined #RubyOnRails
[12:03:57] itarato: has joined #RubyOnRails
[12:03:59] GioVdK: has joined #RubyOnRails
[12:04:43] GioVdK: hi, I'd just like to double check with you if I got a couple of concepts right:
[12:04:56] mrbubbles: rwsq1 personally, I'd just write it as a static dashboard, then create API endpoints for any data that you want to refresh dynamically. Then just use jQuery to query these on a timeout, periodically updating the components as needed
[12:05:18] GioVdK: when deploying a rails app, using bundle install --deployment will store the gems locally in vendor/bundle
[12:05:32] mrbubbles: If you're feeling flashy you could replace the jquery with react components, but wrapped in the normal rails views.
[12:06:01] GioVdK: and then in production you can run rake assets:precompile to pre-compile your assets, right?
[12:07:33] GioVdK: however doing so I noticed that rake is also looking inside of vendor/ and therefore trying to read all the gems
[12:10:20] GioVdK: which then lead to https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers
[12:11:33] GioVdK: does it make sense for rake to look into those?
[12:11:57] itarato1: has joined #RubyOnRails
[12:15:09] itarato2: has joined #RubyOnRails
[12:16:48] xall_: has joined #RubyOnRails
[12:18:12] dminuoso: What's that jQuery you are talking about? :|
[12:19:52] dminuoso: rwsq1: And turbolinks is far from being perfect. It's just a dirty hack to give an enduser the impression and speed of a SPA. At the same time the developer suffers from still catering to a static many-page application with a transparent library that constantly fucks with events.
[12:20:50] rwsq1: ACTION throws turbolinks in the bin
[12:21:46] itarato3: has joined #RubyOnRails
[12:23:13] itarato4: has joined #RubyOnRails
[12:30:34] itarato4: has joined #RubyOnRails
[12:32:11] urkle: has joined #RubyOnRails
[12:35:53] dionysus69: has joined #RubyOnRails
[12:38:29] xall: has joined #RubyOnRails
[12:41:58] itarato4: has joined #RubyOnRails
[12:46:10] shilon: has joined #RubyOnRails
[12:49:02] ar1a: has joined #RubyOnRails
[12:49:07] ar1a: !tutorial
[12:52:18] itarato4: has joined #RubyOnRails
[12:52:20] aajjbb: has joined #RubyOnRails
[12:53:35] adlerdias: has joined #RubyOnRails
[12:56:39] ar1a: any recommendations?
[12:56:50] xall: has joined #RubyOnRails
[12:57:25] Technodrome: has joined #RubyOnRails
[12:58:36] helpa: Rails 4 in Action - http://manning.com/bigg2 - An excellent book combining Rails and TDD/BDD development. Written by Rebecca Skinner, Steve Klabnik, Ryan Bigg, Yehuda Katz
[12:58:47] sevenseacat: dammit... need a good rails 5 resource
[13:00:36] bmgoog: Anyone know if Alchemy CMS works with Rails 5?
[13:02:13] waseem_: ar1a: https://www.railstutorial.org/book
[13:04:09] pupsicle: has joined #RubyOnRails
[13:07:53] dionysus69: has joined #RubyOnRails
[13:08:17] ar1a: i cant afford to buy a book but that one looks like its online :P
[13:15:50] xall_: has joined #RubyOnRails
[13:16:29] shilon: has joined #RubyOnRails
[13:18:19] gabeodess: has joined #RubyOnRails
[13:20:01] gabeodess: Good morning! What are people’s opinions on encoding BigDecimals to JSON? I want it to be encoded as a number (default is to convert it as a string). Should I use the 'activesupport-json_encoder' gem to accomplish this? Do I lose something by reverting to that gem (besides the small amount of floating point precision)? How do other people handle this problem?
[13:20:09] Pumukel: has joined #RubyOnRails
[13:20:15] romeoh: has joined #RubyOnRails
[13:20:43] jphase: has joined #RubyOnRails
[13:23:09] cedum: has joined #RubyOnRails
[13:23:58] gabeodess: Actually, it doesn’t look like that gem supports Rails 5 at this time… how are people solving this?
[13:31:18] xall: has joined #RubyOnRails
[13:34:12] DrYockel1: has joined #RubyOnRails
[13:36:35] itarato4: has joined #RubyOnRails
[13:38:25] mrbubbles: bmgoog There is a Rails 5 branch but it's not production ready, I don't think
[13:38:34] mrbubbles: Which is a shame as it's the best CMS I've found
[13:46:37] xall: has joined #RubyOnRails
[13:47:23] DLSteve: has joined #RubyOnRails
[13:48:03] bruno-: has joined #RubyOnRails
[13:52:10] Technodrome: has joined #RubyOnRails
[13:52:32] xall_: has joined #RubyOnRails
[13:53:41] shilon: Hello there, anyone used Devise with Devise_Invitable?
[14:05:26] shilon: has joined #RubyOnRails
[14:08:24] rakm: has joined #RubyOnRails
[14:14:00] ResidentBiscuit: has joined #RubyOnRails
[14:14:25] ResidentBiscuit: has joined #RubyOnRails
[14:14:50] ResidentBiscuit: has joined #RubyOnRails
[14:15:06] xall: has joined #RubyOnRails
[14:15:15] ResidentBiscuit: has joined #RubyOnRails
[14:15:39] Rodya_: has joined #RubyOnRails
[14:17:13] shilon: Hello, is there any help at all here?
[14:17:27] sevenseacat: waiting for you to ask your real question
[14:18:12] shilon: I have a User model with a validation first_name, but I’m using Devise and Devise Invitable. When registering a User I want to force first_name but not when I’m inviting a user…
[14:18:46] sevenseacat: http://guides.rubyonrails.org/active_record_validations.html#conditional-validation
[14:18:58] shilon: both devise and devise invitable are asking for the first_name, I’ve tried this approach but it didn’t work.. https://richonrails.com/articles/skipping-validations-in-ruby-on-rails
[14:19:14] sevenseacat: you may want to only validate first name if the invitation token is nil, for example.
[14:19:30] shilon: can’t I do it based on controller?
[14:19:40] sevenseacat: model validations have nothing to do with controllers.
[14:19:40] shilon: I wanted to do something like
[14:19:57] jphase: has joined #RubyOnRails
[14:20:01] shilon: validates if: RegistrationsController
[14:20:11] shilon: so if it’s invitationsController it wont validate...
[14:20:39] shilon: on the url you sent me
[14:20:40] sevenseacat: what about when you invite a user from the console?
[14:20:50] sevenseacat: or somewhere other than a controller?
[14:21:01] shilon: yeah, I understand :)
[14:21:25] cam27: has joined #RubyOnRails
[14:21:28] shilon: have you seen the url I’ve sent you?
[14:21:33] shilon: is that legit?
[14:21:45] shilon: beucase I’ve tried it and for some reason it didn’t work
[14:21:49] sevenseacat: i didnt look, no.
[14:22:07] shilon: , unless: :skip_name_validation
[14:22:24] sevenseacat: thats the same idea I gave you
[14:22:26] shilon: and adding to the create controller the @user.skip_name_validation = false
[14:22:39] shilon: but I don’t know why, it didn’t work..
[14:22:47] shilon: I’ll try again
[14:22:50] sevenseacat: because your model doesnt have a skip_name_validation method
[14:22:58] sevenseacat: so trying to set it will raise an error
[14:23:33] sevenseacat: why bother with extra data when you already have the deciding factor, the invitation token, right there?
[14:23:33] shilon: so inside the skip_name _validation I should add invitation_token == nil???
[14:24:14] shilon: sorry, I’m a noob
[14:25:23] sevenseacat: okay, so which part don't you understand
[14:25:33] shilon: sevenseacat: your idea will not work :/ because when inviting users the update invite asks for the name and it has the invitation_token...
[14:25:44] sevenseacat: remember that it's always easier for you to try things than ask me if things will work
[14:26:16] sevenseacat: well you didnt specify what should happen in that scenario, whether it should validate or not
[14:26:25] shilon: I have create registrations, create invitations and update invitations. The only place I don’t want to ask the name is when creating invitations
[14:26:41] shilon: yes, I know. But now I’m thinking about it :P
[14:27:17] shilon: so basically I want to validate the name in creating registrations and updating invitations but not in creating invitations…
[14:27:23] shilon: it’s complicated right?
[14:27:28] sevenseacat: so you only want to skip the validation on create and if the token is present
[14:27:48] shilon: but the problem is that the create registrations and create invitations uses the same User model...
[14:27:56] shilon: so I don’t know how can I do this..
[14:28:00] sevenseacat: again, use the presence of the token
[14:28:19] sevenseacat: i'm not going to write the code for you
[14:28:43] shilon: let me try that
[14:30:20] chouhoulis: has joined #RubyOnRails
[14:30:53] workmad3: has joined #RubyOnRails
[14:33:50] rakm: has joined #RubyOnRails
[14:34:30] shilon: sevenseacat: https://gist.github.com/jamesalbuquerque/cf93cd01832515bdbb9d2289ca8cd54b
[14:42:05] duderonomy: has joined #RubyOnRails
[14:44:35] apparition: has joined #RubyOnRails
[14:52:47] patarr: has joined #RubyOnRails
[14:53:41] schuylr: has joined #RubyOnRails
[14:55:03] dionysus69: has joined #RubyOnRails
[14:55:44] schuylr: Has anyone encountered an issue when upgrading from Rails 5.0 to 5.1 where the stack-trace exception pages no longer appear in development mode? I haven’t changed config.consider_all_requests_local = true in my development.rb and went through the upgrade guide and rails app:upgrade. The only thing that causes this issue is when I switch from my Rails 5.0 branch to my upgraded Rails 5.1 branch…
[14:56:29] Pumukel: has joined #RubyOnRails
[15:01:50] Pumukel: has joined #RubyOnRails
[15:02:04] Rodya_: has joined #RubyOnRails
[15:05:15] Pumukel: has joined #RubyOnRails
[15:06:42] chouhoulis: has joined #RubyOnRails
[15:11:23] AzaToth: has joined #RubyOnRails
[15:12:41] itarato4: has joined #RubyOnRails
[15:17:24] gabeodess: schuylr: yes. I don’t know what causes it.
[15:19:34] schuylr: It’s driving me crazy. I tried explicitly setting config.action_dispatch.show_exceptions = true too and it doesn’t work
[15:19:58] schuylr: I’m running a Vagrant box, are you running in a VM as well?
[15:20:30] somerandomteen: has joined #RubyOnRails
[15:21:38] arBmind: has joined #RubyOnRails
[15:22:15] somerandomteen: Hey all! Ruby newbie here :) If I have a model called "Model", and that model has a property in the database called Category, which is stored in a non-human-readable format, how's best to convert it to human-form? Should I make a method for @model.category.humanize, or should I make a helper that goes humanize_category(@model.category)?
[15:24:52] mikecmpbll: somerandomteen : the latter. the former would require extending/patching String or serializing/deserialising your own type .
[15:25:22] mikecmpbll: the latter is also generally preferred to @model.human_category which you didn't mention
[15:25:28] gabeodess: schuylr: I am not. Running OSX Sierra
[15:25:41] somerandomteen: Fair enough - the first seemed ruby-esque, so I wondered if there was a way to do it is all :) the latter seems Pythonic-esque Thanks mikecmpbll!
[15:26:02] somerandomteen: "@model.human_category"? bleh! new to ruby, not to aesthetic programming :P
[15:26:07] schuylr: gabeodess: “rails s” server or a passenger/nginx or puma type configuration?
[15:26:24] gabeodess: schuylr: rails s
[15:26:34] schuylr: interesting, completely different from me then
[15:26:38] gabeodess: schuylr: I believe rails s uses puma now
[15:26:54] tbuehlmann: somerandomteen: I'd have a helper or decorator method human_category which would use i18n
[15:26:56] schuylr: I’m still running nginx/passenger
[15:27:24] somerandomteen: tbuehlmann: that's what I thought :) thanks!
[15:27:28] schuylr: gabeodess: Ruby version?
[15:27:50] gabeodess: schuylr: 2.4.1
[15:28:18] schuylr: and I’m 2.3.0 (which I’m upgrading now0
[15:30:16] tercenya: has joined #RubyOnRails
[15:33:09] brent__: has joined #RubyOnRails
[15:33:37] brent__: has joined #RubyOnRails
[15:40:48] Pumukel: has joined #RubyOnRails
[15:41:33] GeorgesLeYeti: has joined #RubyOnRails
[15:42:42] theunraveler: has joined #RubyOnRails
[15:43:09] GeorgesLeYeti: Is it possible to disociate log file for errors. Like puma (puma_access / puma_error) or nginx ?
[15:45:36] xall: has joined #RubyOnRails
[15:47:12] bobbobbins: has joined #RubyOnRails
[15:48:34] greghoggard: has joined #RubyOnRails
[15:50:03] bobbobbins: has joined #RubyOnRails
[15:55:20] iDavid: has joined #RubyOnRails
[15:55:24] Pumukel: has joined #RubyOnRails
[15:55:35] Pumukel: has joined #RubyOnRails
[15:55:55] greghoggard: Hi everyone. I am having trouble dealing with rerendering a fields_for partial. I am using a method in my application helper that allows me to add new fields and each one of these fields saves on change through JS. The first one saves perfectly fine and creates a new record, but any subsequent changes cause a new record to be created.
[15:56:04] itarato4: has joined #RubyOnRails
[15:56:50] dionysus69: has joined #RubyOnRails
[15:57:21] greghoggard: I know this is because there is no hidden_field attached to the fields_for unless the page is reloaded. I have tried a million different ways to try to rerender the fields_for partial to reload it with the correct hidden_field but I cant seem to get it right. If anyone could look and see what i'm doing wrong it would be greatly appreciated
[15:57:22] ascarter: has joined #RubyOnRails
[15:57:25] greghoggard: https://gist.github.com/greghoggard/49c03bb7c2d754c02829e97ae1212bfd
[16:02:42] rakm: has joined #RubyOnRails
[16:03:21] Rodya_: has joined #RubyOnRails
[16:04:32] ar1a: why is every tutorial i look at for a blog or something
[16:04:37] ar1a: like, half copy and paste
[16:04:43] ar1a: "im just gonna copy and paste in some code i wrote"
[16:04:47] ar1a: HOW DOES THIS HELP ME
[16:08:12] ResidentBiscuit: has joined #RubyOnRails
[16:10:10] ych: has joined #RubyOnRails
[16:10:34] ascarter: has joined #RubyOnRails
[16:11:04] gusrub: has joined #RubyOnRails
[16:11:23] schuylr: greghoggard: Are you talking about this part? https://gist.github.com/greghoggard/49c03bb7c2d754c02829e97ae1212bfd#file-application_helper-rb-L23
[16:11:59] arBmind: has joined #RubyOnRails
[16:12:05] greghoggard: I guess. I dont know if that is causing the problem or its my update.js.erb
[16:12:08] schuylr: I don’t think you’re going to get hidden fields in a pure Ruby enumerator context, you need the <%= or something special to capture that
[16:12:18] greghoggard: ActionView::Template::Error (undefined local variable or method `analyses' for #<#<Class:0x007f860c06ec50>:0x007f8618656b20>):
[16:12:27] greghoggard: thats the most recent error when i try to rerender
[16:12:45] greghoggard: I cant figure out what to pass in to get the field to rerender
[16:13:17] schuylr: Most recent error? Did you change the code from the gist?
[16:13:48] bobbobbins: has joined #RubyOnRails
[16:13:56] baweaver: ar1a: was there a question in there somewhere?
[16:14:02] baweaver: or just expressing anger?
[16:14:18] greghoggard: no i havent changed the code
[16:14:39] greghoggard: just stating that that is the error i am getting
[16:14:43] baweaver: ar1a: See the book list in the channel topic. A few of them are detailed guides to various components of Rails
[16:14:58] schuylr: greghoggard: You’re overriding “f” in your update.js.erb partial from a form enumerator to an Array
[16:15:08] shilon: has joined #RubyOnRails
[16:15:22] greghoggard: i'm not quite sure
[16:15:40] greghoggard: like i said, i'm not really sure what the correct syntax should be
[16:15:52] schuylr: It needs the context from form_for
[16:16:40] greghoggard: so should i change the f in the fields_for partial to a different variable?
[16:16:54] greghoggard: and then pass that in to the update action
[16:17:36] schuylr: That probably won’t work. You don’t seem to understand what’s going on - are you following a tutorial or something?
[16:18:55] bruno-: has joined #RubyOnRails
[16:18:57] greghoggard: I guess technically? It was a variation of a railscast code to dynamically add fields to a form
[16:19:14] schuylr: Would be good to see that example
[16:20:05] tbuehlmann: greghoggard: that looks a lot like cocoon, have you thought about using that instead of rolling your own?
[16:20:25] schuylr: As we always say here in our office, “is there a gem for that?”
[16:21:19] greghoggard: I'll give it a look
[16:21:45] kristofferR: has joined #RubyOnRails
[16:22:08] chouhoulis: has joined #RubyOnRails
[16:22:38] schuylr: I’m going down a rabbit hole trying to find where Action Dispatch ultimately determines whether to show the PublicExceptions or DebugExceptions page to figure out this Rails 5.0 and 5.1 issue...
[16:22:39] greghoggard: I have looked at it before, and i noticed how it gave pretty much the same functionality. The problem I have is the refreshing the partial to include the hidden id field of the newly created nested object
[16:22:52] mikecmpbll: sounds a lot like ryanb's nested_form also; https://github.com/ryanb/nested_form/blob/master/lib/nested_form/builder_mixin.rb#L19
[16:22:57] ar1a: baweaver: expressing anger
[16:23:05] ar1a: also i dont know how to view the entire topic line on weechat
[16:23:09] ar1a: /topic doesnt seem to do anything
[16:23:19] tbuehlmann: greghoggard: you mean the parent's object id?
[16:23:20] baweaver: Book List: http://goo.gl/SGklzh
[16:23:40] baweaver: The Rails * Way is your tome style book that covers all the things
[16:23:42] ar1a: i cant afford to buy any :L
[16:24:06] schuylr: “Free books are tagged with (F)”
[16:24:16] helpa: ar1a : For the rails API, check out http://api.rubyonrails.org/
[16:24:18] mikecmpbll: ar1a : !guides
[16:24:18] helpa: ar1a : http://guides.rubyonrails.org/ - Ruby on Rails guides. Recommended reading.
[16:24:26] mikecmpbll: all you need :p
[16:24:36] ChanServ: +o baweaver
[16:24:45] ar1a: instead of looking at api docs i rather implementation examples
[16:24:52] ChanServ: -o baweaver
[16:24:59] mikecmpbll: ar1a : see 2nd link.
[16:25:54] schuylr: Anyone familiar with ActionDispatch know where I can find the router that ultimately decides between Public/Debug Exceptions? Trying to hunt down a potential bug
[16:28:11] ar1a: mikecmpbll: yeah but those are *just* using rails
[16:28:12] ResidentBiscuit: has joined #RubyOnRails
[16:28:16] ar1a: what about auth, dashboards, etc
[16:28:22] matthewd: schuylr: https://github.com/rails/rails/blob/4b969ea417f097d217ff1f662d2fe8c406d21b99/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb#L68, and 10 lines down
[16:28:44] matthewd: schuylr: My guess would be that the framework's getting loaded too early, before it's been fully configured
[16:29:05] schuylr: Race condition?
[16:29:07] guacamole: has joined #RubyOnRails
[16:30:04] schuylr: I actually saw that before, so I’ve been building a fail right in my controller to see what the values are. Something like this:
[16:30:05] schuylr: fail "Local Request: #{request.local?.to_s}, All Requests Local: #{Rails.application.config.consider_all_requests_local.to_s}, Show Exceptions: #{request.show_exceptions?.to_s}, Show Detailed Exceptions: #{request.get_header('action_dispatch.show_detailed_exceptions')}"
[16:30:06] mikecmpbll: ar1a : respective gem documentation usually contains comprehensive guides
[16:30:22] schuylr: So far all of them have returned true except for request.local? which is just nil
[16:33:42] schuylr: ar1a: for example with auth, you can check out devise and its respective wiki https://github.com/plataformatec/devise/wiki LOTS of getting started, how-to articles, etc.
[16:34:43] Cache_Money: has joined #RubyOnRails
[16:36:04] Cache_Money: I have an `expiration_date` field in a form that I'd like the user to fill out. I"m having trouble in my form_for helper figuring out how to do that. What am I doing wrong? `<%= f.select_date(:expiration_date, :order => [:month, :day, :year]) %>`
[16:36:27] ar1a: what's not working?
[16:37:06] Cache_Money: ar1a: I'm just not sure how to present a date selector within my form_for view
[16:37:11] matthewd: schuylr: I'd be adding debugging to those lines and checking what they're seeing
[16:37:45] schuylr: matthewd: thanks, I’ll try that after doing a minor version upgrade, just noticed 5.1.1 is out and it could have been fixed without me knowing it
[16:37:47] matthewd: schuylr: Note that you're looking at the config value for consider_all_requests_local, which is not where AD is looking
[16:38:22] schuylr: matthewd: AD is ultimately looking at the actiondispatch.show_exceptions header, right?
[16:38:37] matthewd: It's not a known issue, though it's entirely possible whatever's causing it got changed in a relevant way, I guess
[16:39:15] itarato4: has joined #RubyOnRails
[16:39:55] schuylr: 5.1.1 definitely doesn’t fix it
[16:40:11] Cache_Money: ar1a: Nevermind, figured it out: `<%= f.date_select :expiration_date %>`
[16:40:15] matthewd: Right. (Though I'm struggling to keep track of the difference between show_exceptions and show_detailed_exceptions)
[16:41:07] ar1a: Cache_Money: thats great!
[16:41:13] ar1a: i wouldn't have known, but i tried to save you time ;p
[16:41:39] matthewd: schuylr: You're definitely hitting the PublicExceptions, not an in-app rescue_from or something?
[16:41:57] matthewd: I guess a check inside DebugExceptions would confirm that too
[16:42:40] Cache_Money: ar1a: you wouldn't know how to apply Bootstrap styles to the date picker, would you?
[16:43:21] schuylr: matthewd: I’ll try to throw some Rails.logger.debug lines into that class
[16:43:38] schuylr: but no, nothing application specific otherwise Rails 5.0 would not be doing this to me
[16:44:03] schuylr: i actually have two branches only difference between them are the Gemfile and Gemfile.lock for the 5.0 and 5.1 versions
[16:46:00] schuylr: one quick theory before I go too far with this too, I’m going to see if the web-console gem is causing exceptions that are getting rescued with a public one. I had it version locked to ~> 2.0
[16:48:54] schuylr: matthewd: Fixed by upgrading web-console gem. Do you think I should submit a suggestion for 2.0 to add a rails_version requirement of “< 5.1”? https://github.com/rails/web-console/blob/2-x-stable/web-console.gemspec
[16:49:00] ar1a: Cache_Money: no sorry
[16:49:11] schuylr: Cache_Money: You might be able to find a bootstrap gem to do that
[16:49:53] matthewd: schuylr: Not much point now; it'd prevent people from upgrading to 2.next, but wouldn't give any information
[16:50:16] matthewd: schuylr: So was the exception it was trying/failing to report different from the original one in your code?
[16:50:55] matthewd: If a second exception is occurring while handling the first, while it obviously can't be shown, it should get logged :/
[16:51:10] schuylr: matthewd: I see. Something in the upgrade guide maybe? I wouldn’t have added the `~> 2.0` lock unless the gem instructions told me to. And yes, there was nothing else other than the original exception
[16:51:19] schuylr: Maybe I should check my passenger error logs
[16:52:07] schuylr: Yep, it got bumped to the higher-level passenger logs
[16:52:44] matthewd: Hmm. That does seem less than ideal.
[16:53:10] schuylr: Should I post the gist of that exception here or throw it in an issue for web-console, or something else?
[16:53:23] schuylr: I agree. I could have saved a lot of time if that exception showed up in development.log
[16:53:49] matthewd: Yeah, if you could just gist anything that seems relevant, I'll see if there's anything we can do to improve it
[16:54:04] FCser: has joined #RubyOnRails
[16:54:21] matthewd: I suspect it's a Rails thing, rather than web-console -- it's on us to better handle a failure of the thing that's supposed to be handling the original error
[16:55:07] schuylr: It’s a tricky case, since web-console is extending the Exception middleware, it might be hard to support that
[16:56:06] schuylr: Also seeing that newrelic gem is adding their own handling… maybe that is a contributing factor
[16:56:14] schuylr: https://gist.github.com/schuylr/0f268349d854391fa1e40effb738b453
[17:01:42] schuylr: matthewd: I updated the gist to show the exception with and without the newrelic gem for easier tracing
[17:04:46] drale2k_: has joined #RubyOnRails
[17:04:56] duderonomy: has joined #RubyOnRails
[17:06:18] User458764: has joined #RubyOnRails
[17:11:18] shilon: has joined #RubyOnRails
[17:14:22] Technodrome: has joined #RubyOnRails
[17:18:57] tercenya: has joined #RubyOnRails
[17:19:52] matthewd: schuylr: Genadi's going to see what we can do to make this more obvious in future. Thanks!
[17:20:20] schuylr: matthewd: Happy to help out and thanks for your patience while I figured it out :)
[17:25:55] xall: has joined #RubyOnRails
[17:27:28] itarato4: has joined #RubyOnRails
[17:32:16] schuylr: has left #RubyOnRails: ()
[17:40:38] ascarter: has joined #RubyOnRails
[17:42:27] quirkycoders: has joined #RubyOnRails
[17:47:47] Rodya_: has joined #RubyOnRails
[17:49:33] JDeen: Hello... can some one help me with a regex. I need to remvoe periods in a email user name. Ex: u.s.e.r@example.com -> user@example.com. How can i write this in a regex?
[17:50:34] itarato4: has joined #RubyOnRails
[17:56:43] tbuehlmann: jdeen: what about splitting on '@' and .gsub('.', '') on the first part?
[17:58:05] fryguy: jdeen: also you probably don't want to do that, as I think you are making assumptions about email address validity that aren't true
[17:58:35] itarato4: has joined #RubyOnRails
[17:59:27] Darmani: has joined #RubyOnRails
[17:59:39] Darmani: How do I center this red div inside this blue div?
[17:59:40] Darmani: https://jsfiddle.net/tnf1d7mm/
[18:00:37] defsdoor: has joined #RubyOnRails
[18:00:49] JDeen: tbuehlmann: ya thats what I ended up doing. Thanks.
[18:01:09] tomasm-: has joined #RubyOnRails
[18:01:31] tbuehlmann: Darmani: maybe this helps: http://howtocenterincss.com/
[18:01:55] tomasm-: hey, does rvm/rbenv install ruby globally or just for my main user? I'm wanting to get it running for rails, and nginx is a different user i think. hoping there's a way to install it globally
[18:02:44] JDeen: fryguy: well I am also worried, but it came in the specification. The idea is sort of validation. the issue states that users (Gmail and sendmail) are able to use different varients of their email. Like user+tag@example.com u.s.e.r@example.com which are technically the same as user@example.com. i fear some other hosts might consider them separate and it will end up getting bounced.
[18:02:56] Darmani: tbuehlmann: Sorry I thought this was css
[18:02:59] Darmani: I always do this lol
[18:03:03] Darmani: thank you though.
[18:03:39] fryguy: jdeen: almost every other host considers them separate
[18:04:06] havenwood: tomasm-: It's easy to install globally with ruby-install: https://github.com/postmodern/ruby-install#synopsis
[18:04:38] tomasm-: havenwood, yet ANOTHER install tool?
[18:04:40] havenwood: tomasm-: This will install globally to /usr/local: ruby-install --system --latest ruby
[18:04:50] alphaatom: has joined #RubyOnRails
[18:05:02] havenwood: tomasm-: It's the install tool most folk use with chruby. You can also use it for RVM or rbenv if you prefer.
[18:05:12] greghoggard: for rails 4.1, how would one go about building a object in a nested for with cocoon in a fields_for?
[18:05:28] ascarter: has joined #RubyOnRails
[18:07:11] Rodya_: has joined #RubyOnRails
[18:07:48] hahuang65: has joined #RubyOnRails
[18:08:29] JDeen: fryguy: ya i just checked few and you are correct
[18:08:39] JDeen: fryguy: thanks
[18:14:29] jphase: has joined #RubyOnRails
[18:16:44] Darmani: has left #RubyOnRails: ()
[18:18:02] Rodya_: has joined #RubyOnRails
[18:18:21] jphase: has joined #RubyOnRails
[18:24:02] shilon: has joined #RubyOnRails
[18:25:05] chouhoulis: has joined #RubyOnRails
[18:31:48] ascarter: has joined #RubyOnRails
[18:37:37] irishfromua: has joined #RubyOnRails
[18:39:59] quazimodo: has joined #RubyOnRails
[18:40:28] conta3: has joined #RubyOnRails
[18:41:04] cam27: has joined #RubyOnRails
[18:41:08] conta3: has joined #RubyOnRails
[18:44:32] bobbobbins: has joined #RubyOnRails
[18:45:36] irishfromua: has joined #RubyOnRails
[18:52:24] rx: has joined #RubyOnRails
[18:53:05] amperry: hey folks, I've got a question about implementing a simple password reset system for a small company (bypassing emails and the like), wherein an admin can reset a user's password to a stupid default, but require them to change it upon next login. More detail here: https://gist.github.com/amp108/c6b934d6af89718fbb97d71b7d4e84df
[18:55:11] simmerz: has joined #RubyOnRails
[18:56:30] simmerz: hi, what’s the correct way to update a timestamp attribute on a model after sending a mail via ActiveJob (.deliver_later)? If I try and use model.update_attribute() in the mailer code, the job repeats ad infinitum
[18:57:25] amperry: I may not have phrased my last sentence there very well, so I'm wondering if (a) I've overlooked something, or (b) something in devise already has it handled.
[18:57:59] simmerz: https://gist.github.com/simmerz/b336fe307454dd8bab9a26dff0e0dcd9 is the non working code (ever repeating)
[18:58:01] itarato: has joined #RubyOnRails
[18:59:53] waseem_: has joined #RubyOnRails
[19:01:37] mikecmpbll: has joined #RubyOnRails
[19:04:13] amperry: simmerz: I'm only a novice, but does this: http://stackoverflow.com/questions/22567358/prevent-infinite-loop-when-updating-attributes-within-after-commit-on-crea -- look like something that may be relevant to your case?
[19:05:10] simmerz: what a good shout amperry !
[19:06:35] simmerz: i was so focused on the mailer itself, it didn’t occur to me to look in the model. thank heavens for teddy bear programming :D
[19:06:52] amperry: happy to help, and happy to be the bear
[19:09:24] simmerz: one that speaks back and gives good input, for that
[19:11:04] lxsameer: has joined #RubyOnRails
[19:14:18] chouhoulis: has joined #RubyOnRails
[19:17:08] itarato: has joined #RubyOnRails
[19:22:04] srinidhi: has joined #RubyOnRails
[19:26:06] ascarter: has joined #RubyOnRails
[19:30:30] arup_r: has joined #RubyOnRails
[19:35:14] itarato: has joined #RubyOnRails
[19:45:17] ascarter: has joined #RubyOnRails
[19:47:23] User458764: has joined #RubyOnRails
[19:48:31] romeoh: has joined #RubyOnRails
[19:54:41] xall: has joined #RubyOnRails
[19:55:25] arup_r: has joined #RubyOnRails
[19:56:32] amperry: https://gist.github.com/amp108/c6b934d6af89718fbb97d71b7d4e84df -- don't know what kind of callback I need to check that a user has reset their password. What I'm using now keeps on redirecting me.
[20:08:39] arup_r: amperry: Are you using devise?
[20:08:56] amperry: arup_r: yes
[20:08:56] tercenya: has joined #RubyOnRails
[20:09:47] arup_r: amperry: http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Recoverable#clear_reset_password_token%3F-instance_method
[20:10:34] arup_r: if it returns true, means user reset the password otherwise not
[20:13:27] amperry: arup_r: that doesn't seem to be the problem, although if that's the proper way to check I'll update my method. The problem seems to be that, when I redirect_to edit_user_password_path, I'm getting stuck in a redirect loop.
[20:14:25] arup_r: ok then need to check what you have inside the password controller
[20:15:11] arup_r: AFAIK, `confirmed_at` is used for confirmation after registration ..
[20:15:44] tercenya: has joined #RubyOnRails
[20:16:15] amperry: arup_r: I've updated the gist with the passwords_controller.rb, but it's just the default one that rails creates when you generate devise.
[20:17:38] amperry: also, my setup is a little unusual, as I'm bypassing any email link confirmation. This is for a small company, and I want the admins to be able to manually reset the passwords and require the users to change their password immediately afterward.
[20:19:06] Silox|: has joined #RubyOnRails
[20:19:34] arup_r: where do you have this action `edit_user_password`
[20:19:50] arup_r: seems like you are using your own, not using devise password controller
[20:20:20] arup_r: can you show the controller which holds edit_user_password action?
[20:20:47] amperry: sure; the route comes from here: edit_user_password GET /users/password/edit(.:format) devise/passwords#edit
[20:24:10] arup_r: amperry: https://gist.github.com/amp108/c6b934d6af89718fbb97d71b7d4e84df#gistcomment-2098173 can u try?
[20:25:13] amperry: arup_r: I'll give it a try. It looks like I'm just moving the method to be protected?
[20:25:38] arup_r: no. that's not first thing. first thing is I changed the logic
[20:26:01] arup_r: and then I protected it, because it is for internal use only
[20:26:36] amperry: ah, ok. One moment...
[20:27:58] amperry: hmmm... it doesn't like the '?' at the end of 'clear_reset_password_token?', but if I take that off, won't it *always* clear it?
[20:28:26] amperry: nope. It doesn't like it one way or the other.
[20:28:27] arup_r: that method is from devise lib. it should work :)
[20:29:01] arup_r: it is method exposed by devise http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Recoverable#clear_reset_password_token%3F-instance_method
[20:29:14] arup_r: can u show your user.rb please?
[20:30:19] ForeignBiscuit: has joined #RubyOnRails
[20:30:24] amperry: sure, one moment
[20:32:00] amperry: arup_r: it has been added
[20:33:06] arup_r: ok what is the error you are getting when used the code I pasted in comment?
[20:33:10] arup_r: show me the error
[20:33:37] amperry: protected method `clear_reset_password_token?' called for #<User:0xb1de0b64> Did you mean? clear_reset_password_token set_reset_password_token
[20:35:27] arup_r: check my comment again in gist
[20:35:38] cagomez: has joined #RubyOnRails
[20:38:11] amperry: arup_r: that at least clears out the error. When I have an admin reset the password, what will I need to do in order to ensure that current_user.reset_password_period_valid? is true?
[20:38:58] arup_r: devise will do it, you don't need to touch it.. while u are using devise controllers
[20:39:44] arup_r: look at the logic of the method to understand how it verifies https://github.com/plataformatec/devise/blob/master/lib/devise/models/recoverable.rb#L71
[20:40:59] amperry: hmm... so I just call, e.g., user.reset_password('CHANGEME', 'CHANGEME'), and they will be required to change it upon next login?
[20:41:44] brendan-: has joined #RubyOnRails
[20:42:08] amperry: whoops. Just logged out and am getting an error.
[20:42:50] arup_r: that method basically resets it.. U need to call http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Recoverable#send_reset_password_instructions-instance_method
[20:43:20] arup_r: that will email the reset link to the user and then user can click on it and reset it by themselves
[20:43:29] hahuang65: has joined #RubyOnRails
[20:44:18] amperry: ah, but I'm trying to avoid sending reset emails.
[20:45:07] amperry: so maybe I'm doing something that just goes against the grain of devise, in which case, I might be out of luck.
[20:46:27] arup_r: so how do you allow your users to reset their password?
[20:47:08] amperry: I don't. This is for a small company, and I intend to have admins be able to reset user passwords with the click of a button.
[20:47:14] duderonomy: has joined #RubyOnRails
[20:47:21] amperry: users will have to contact the admins directly
[20:47:38] jphase: has joined #RubyOnRails
[20:48:48] arup_r: then use user.reset_password() method
[20:48:55] arup_r: that will do the job
[20:49:15] arup_r: U need to add an action to your own controller and do it by yourself.
[20:50:11] arup_r: and u really don't need the callback in the controller if the reset of password is done or not. As when admin will be doing it, it is instant.. so that check is not needed.. as nothing is pending.
[20:50:45] amperry: that I can do, but when the admin resets the user the password, I intend to have it default to a dumb password that the user must reset.
[20:51:14] arup_r: and that means u really want to send an email ..
[20:51:25] arup_r: u are just confusing yourself
[20:52:05] amperry: well, like I said, I'm possibly going against the grain of how devise does things, so I may be out of luck.
[20:52:20] gusrub: has joined #RubyOnRails
[20:52:26] arup_r: no you are not out of luck! :)
[20:52:53] arup_r: You are just not able to understand the flow. devise has things that u are looking for
[20:53:58] arup_r: amperry: so what you will do is, let admin reset their password, and then send immediately a password reset email to the user.. so that user then can reset it again
[20:54:16] arup_r: in this case the method I gave you in the controller is again useful
[20:54:25] arup_r: Do you get what I meant?
[20:54:27] amperry: but does that *require* them to change it?
[20:54:53] arup_r: what do u mean?
[20:55:06] amperry: my expected flow looks like this:
[20:56:20] amperry: user contacts admin, by phone, email, or in person, and requests a password reset; admin chooses whether or not to reset it, and if so, sets it to a dummy password ('CHANGEME') that *must* be changed after the next login; user logs in, and is presented with a form to change their own password.
[20:57:11] amperry: this is not meant to be an application where any number of users can sign up and join, it's just meant to be restricted to employees.
[20:57:16] arup_r: yes, possible. What I said above will work
[20:58:01] amperry: it will work without email getting involved?
[20:59:24] arup_r: don't send the email. Let admin set the password by using #reset_password method and then inside the same action where u are resetting the password, after that do call `set_reset_password_token` method
[20:59:51] mrbubbles: I'm a little confused by Pundit... I'm trying to allow registered users to view via the posts controller, but then only admin users should be able to do view via the admin posts controller. I'm sure this is possible but I'm not sure how - as the models are the same?
[20:59:51] arup_r: and now u are there where u are trying to achieve. :)
[21:00:26] amperry: ah, okay, so when that happens, current_user.reset_password_period_valid? is the method to call?
[21:00:40] amperry: in check_password_reset, that is?
[21:01:15] arup_r: yes.. once u call set_reset_password_token it sets the token and date. so now, current_user.reset_password_period_valid? will return true and user will be redirect to edit password path
[21:01:45] gusrub: has joined #RubyOnRails
[21:01:55] arup_r: and once user reset the password, token will be cleared by devise.
[21:02:14] arup_r: just read this page http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Recoverable#set_reset_password_token-instance_method , it has all methods for you.
[21:02:51] arup_r: if current_user.set_reset_password_token throws error.. use #send to by pass encapsulation. :D
[21:03:42] amperry: I'll give it a try.
[21:03:53] arup_r: ok time to leave and sleep... many good rails folks are not in this channel anymore! :( where is tubbo, smathy etc :/
[21:08:52] marr: has joined #RubyOnRails
[21:11:31] ascarter: has joined #RubyOnRails
[21:11:44] Rodya_: has joined #RubyOnRails
[21:22:58] jphase: has joined #RubyOnRails
[21:25:19] jdqx: has joined #RubyOnRails
[21:27:03] gabeodess: has joined #RubyOnRails
[21:31:24] romeoh: has joined #RubyOnRails
[21:33:42] cagomez: has joined #RubyOnRails
[21:34:47] cagomez: has joined #RubyOnRails
[21:47:22] tercenya: has joined #RubyOnRails
[22:03:31] ascarter: has joined #RubyOnRails
[22:14:38] hahuang65: has joined #RubyOnRails
[22:17:45] luckyruby: has joined #RubyOnRails
[22:19:47] Radar: GOOD MORNING
[22:20:05] romeoh: has joined #RubyOnRails
[22:20:14] romeoh: has joined #RubyOnRails
[22:32:04] amperry: GOOD MORNING, Radar
[22:36:28] amperry: Radar: know much about finagling Devise to do something a little different from ordinary?
[22:36:41] Radar: amperry: how do you mean?
[22:37:10] amperry: Why, I'm glad you asked: https://gist.github.com/amp108/c6b934d6af89718fbb97d71b7d4e84df
[22:38:01] bruno-_: has joined #RubyOnRails
[22:38:27] amperry: It really seems like this would be a simple usage, but I'm spinning my wheels on it.
[22:38:49] Radar: Devise has a way to configure where the user is sent after sign in.
[22:39:04] Radar: after_sign_in_path_for
[22:39:16] Radar: Define that method to check the user's confirmed_at field.
[22:39:19] amperry: conditionally?
[22:39:36] Radar: I would rename confirmed_at to something else, like last_password_reset_at
[22:39:52] amperry: confirmed_at is a field added by devise, or so I thought.
[22:40:22] Radar: It is, but it serves a different purpose to the one that you're adopting it for.
[22:41:24] Rodya_: has joined #RubyOnRails
[22:41:56] amperry: does that mean I'll need to add the field to the db table?
[22:43:05] wethu: has joined #RubyOnRails
[22:43:24] Radar: Yeah, I would add another field for this purpose.
[22:44:09] cam27: has joined #RubyOnRails
[22:44:31] amperry: k; so right now, the plan is: add last_password_reset_at to users table, change after_sign_in_path_for (where?), and then use the last_password_reset_at in application_controller#check_password_reset
[22:45:10] Radar: You can define custom behaviour for after_sign_in_path_for in ApplicationController.
[22:45:12] shilon: has joined #RubyOnRails
[22:45:17] Radar: Just define the method there.
[22:45:54] amperry: as per https://github.com/plataformatec/devise/wiki/How-To:-redirect-to-a-specific-page-on-successful-sign-in, perhaps
[22:47:23] amperry: and *that* method should have the check to see if last_password_reset_at is nil, then redirects based on whatever I decide? (And therefore, we don't need application_controller#check_password_reset at all?)
[23:00:57] amperry: Radar: care to take a look at what I have? I don't know what else I need to do to get it to work, but it seems like it's letting me login regardless. Same gist, https://gist.github.com/amp108/c6b934d6af89718fbb97d71b7d4e84df
[23:02:04] Radar: amperry: if it's letting you in regardless then I would check the condition in after_sign_in_path
[23:02:16] Radar: https://gist.github.com/amp108/c6b934d6af89718fbb97d71b7d4e84df#file-application_controller-rb-L7-L13
[23:02:21] Radar: Is it actually getting to this point?
[23:03:05] amperry: lemme check
[23:03:55] amperry: apparently not
[23:04:42] amperry: dammit, me using backwards logic
[23:06:50] amperry: well, now at least it's redirecting me somewhere where I don't have a route, which is progress :)
[23:07:37] jphase: has joined #RubyOnRails
[23:08:13] quirkycoders: has joined #RubyOnRails
[23:14:23] Fire-Dragon-DoL: has joined #RubyOnRails
[23:17:10] amperry: Radar: hrm. Just as a test I replicated the GET route that devise provides as a POST route, and now I'm running into the 'redirected too many times' error in the browser and a 'Filter chain halted as :require_no_authentication rendered or redirected' message in the logs.
[23:18:55] amperry: Since I'm bypassing :recoverable, I can take that module out, in which case I get to the root path with a flash alert saying I'm already logged in.
[23:19:55] amperry: and that gives me an error when I log out and back, durnit.
[23:29:57] amloelxer: has joined #RubyOnRails
[23:33:20] amloelxer: has left #RubyOnRails: ()
[23:42:40] Rodya_: has joined #RubyOnRails