#RubyOnRails - 31 October 2018
« Back 1 day Forward 1 day »
[05:45:33] dachi: Hi. I have a question, I've been working for the while and in vain. May I ask for help?
[05:49:57] dachi: We have a domain and 4 subdomains, I need to isolate one subdomain from others (domain and 3 subdomains), so that it has a separate session-cookie-store.
[05:50:24] dachi: I tried writing a middleware and it looked like specs passed, but from closer look it was not functioning correctly.
[05:51:21] dachi: I mean I need *system.domain.com* to have its own session cookie store and *domain.com*, *docs.domain.com*, *portal.domain.com*, *blog.domain.com* to have own
[07:28:00] dachi: How can I dynamically change session key? request.env['rack.session.options'][:key] = does not work in Rails 5
[07:52:57] dachi: How can I dynamically change session key? request.env['rack.session.options'][:key] = does not work in Rails 5
[11:03:03] noob69: Hi, so I'm using searchkick. I need to know if we can create multiple indexes for the same model.
[12:44:02] jhass: just ask and stick around for an hour or two, if anybody is available with an answer to your question, they'll respond
[12:49:04] Cork: anyone know if there is a way to "unmark_for_destruction" a related active record object?
[12:49:22] Cork: i can only find mark_for_destruction and marked_for_destruction? but i need to reset the state
[12:55:11] dachi: @Cork is not it reload ? Reloads the attributes of the object as usual and clears marked_for_destruction flag.
[12:56:25] Cork: very hackish but... obj.instance_variable_set("@marked_for_destruction", false) "works", though i would love to have an exposed api...
[12:58:09] dachi: Cork: I don't think it's implemented there yet... But maybe someone knows better than me and will respond
[12:59:39] dachi: I have a question too, I've been working on for quite a while and if anybody has time to listen, please write
[13:10:52] helpa: Check your logs. Namely everything in the log folder of your rails app and the error and access logs from Apache or whatever else you're using.
[13:15:29] Cork: else you can toggle the parent object and then toggle it back and get the wrong result
[13:16:04] Cork: sure i can say "if you toggle this and want to restore it you have to reload the entire object relation"
[13:16:18] jhass: mh, I guess I'd consider just doing my own flag and doing consistent state with an after_save callback
[13:16:45] Cork: ya, but the problem is we have things hooked into the after_commit hook that needs to get the correct data
[13:17:54] jhass: maybe there's something wrong in the data model, actual terms would help thinking about that point :)
[13:18:53] Cork: jhass: ya, but it is a kinda silly big relation, we have extended active_record quite heavily (it is a relly old project, we hopefully will replace it in about a year)
[13:18:55] jhass: dachi: maybe it would be simpler if you use the same session but different keys within the session?
[13:20:07] dachi: jhass: that's another thing that I wanted to achieve, but request.env['rack.session.options'][:key] = "..." does not work in Rails 5
[13:20:30] dachi: jhass: before I was trying to write a middleware that would dynamically set domains
[13:20:55] jhass: no, I mean instead of using idk, "current_user_id", for the system. part use "current_system_user_id" etc
[13:26:59] dachi: And people around my project demand to get rid of this "dual-system", they want it isolated, because a lot of unwanted things occur
[13:28:04] jhass: does your admin thing even share much domain logic? maybe it could be its own thing?
[13:30:04] dachi: jhass: I wanted to ask around my project if setting that subdomain from nginx and running another app on it would be a better option, but unfortunately it looks like they want to keep it as it is.
[13:31:10] dachi: I don't know why it even is such a big deal, I was thinking that changing cookie name according to request info would not be that big of a hussle
[13:41:49] jhass: maybe you have some luck with deriving your own session store from ActionDispatch::Session::CookieStore and overriding load_session/delete_session to reset options[:key] based on the host in req
[13:44:01] jhass: https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/middleware/session/cookie_store.rb / https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb / https://github.com/rack/rack/blob/master/lib/rack/session/abstract/id.rb#L202
[14:00:54] dionysus69: nice nice, I couldnt help you with that question, I never done such a thing so :)
[14:01:38] dionysus69: yes I am fine, same to you, if you need a rails job give me facebook ping btw, we maybe looking for an extra employee ^.^ if you are in Georgia :)
[14:04:51] dionysus69: oh yes yes, say hi to him, let's move to #RubyOnRails-offtopic btw before one of the Jedies gives us a notice
[16:18:49] Psy-Q: this is just an experimental class i'm throwing together, but why in the world would https://dpaste.de/xO2f#L49 not work? it throws NoMethodError (undefined method `fish' for #<Hosting:0x000056516f27e090>). the "same" methods further up work fine
[16:49:42] dachi: jhass: yeah, you mean Persisted.class_eval, you think @key will be there from custom store already? cool, i'll check
[16:51:00] jhass: so I would imagine just overriding extract_session_id in your custom store is enough
[16:51:57] jhass: not sure how I feel about copying implementation vs just setting @key and calling super, both is hackish but I think personally I'd prefer calling super
[17:03:46] mwlang: I think I’ve forgotten something subtle about ActiveRecord. Why would deleting a child record that belongs to a parent class issue a DELETE for the parent record? The child class depends on the the parent, so if parent is being destroyed, sure, delete the child, but not the other way around...
[17:29:03] dachi: mwlang: So you delete a record that belongs to some other record from another model and that model's record is destroyed?
[17:29:51] mwlang: I started a transaction block, deleted all the child records, then deleted the parent record at the end of that transaction block.
[17:30:23] mwlang: it’s the call to delete the parent record that’s triggering the FK constraint on the child table (whose records I’ve already deleted…)
[17:30:55] mwlang: the DBMS just isn’t seeing the record as deleted yet, so it’s the DBMS raising the FK constraint error, not AR.
[17:54:24] hightower3: Hey, I want get(), post() etc. to be available in all rspec tests and not just ones of type: request. How do I do that?
[17:59:52] dachi: hightower3: i don't think it's good way to write specs, but I think you can hack it
[18:00:00] hightower3: Got it, I needed line "config.include RSpec::Rails::RequestExampleGroup" inside RSpec.confgure()
[18:00:55] hightower3: dachi, I want to do it because all my requests need it, and for some which don't (but which aren't that much different) it makes no sense to painstakingly control where do I add type: request and where not
[18:16:50] broppk: Hi there. I have a lot of experience with Node and realize it might be faster to get going on a project with that as my first choice. However, I'm growing a little weary with some of the decisions I have to make mapping out a project structure. Is Rails a good solution worth going after in 2018 even if I have limited experience and might have to do a bit of catching up?
[18:20:16] hightower3: broppk, you're asking the question in front of a biased audience :) but sure, start with that video tutorial on rubyonrails.org and the couple intro documents found there
[18:28:23] dachi: broppk: I'd suggest taking look at popular gems like Devise, Faraday, Paperclip, Sidekiq, etc. Perhaps understanding how they work might give you a good knowledge
[18:43:13] dachi: broppk: I also think that after being able to do basic rails-stuff like handling routes, mvc things, assets, environments, initializers
[18:44:18] dachi: Things like Rack, ActionDispatch, ActionController, ActiveSupport, AbstractController, ActionView
[19:16:14] mwlang: broppk: 12 years later, Ruby is still my go-to language of choice and I don’t see myself giving it up any time soon. I do some Node JS, but mostly within context of a Rails project, which means React and Webpack, etc. tied into a Rails-driven backend serving the databased JSON to the JS frontends.
[19:17:19] dachi: to me rails webpacker is awesome, react works pretty well, incl. serverside rendering
[19:19:57] mwlang: most of the latest JS stuff is still arm’s length for me. I can usually do all the JS I need with simple jQuery widgets written in coffeescript. If I need more, I usually step up to VueJS instead of React, Webpack and all that. Only two projects are utilizing the heavier weight JS tooling.
[19:21:22] mwlang: I guess it all goes back to the RJS days of Rails and since that big ball of mud, I’ve always tried to keep external components to a bare minimum.
[23:55:15] bmon: Hi all! I have a model with a jsonb field which is behaving very strangely. When I store an instance of this model into a variable, the attributes value for my jsonb field gets silently mutated! Here's a paste: https://dpaste.de/rU4z