« Back to channel list

#RubyOnRails - 08 February 2018

« Back 1 day Forward 1 day »
[00:02:03] mtkd: has joined #RubyOnRails
[00:05:05] glassresistor: has joined #RubyOnRails
[00:22:11] cnk: has joined #RubyOnRails
[00:24:48] TinkerTyper: has joined #RubyOnRails
[00:39:09] glassresistor: has joined #RubyOnRails
[00:51:00] budfox: has joined #RubyOnRails
[00:53:21] cagomez: has joined #RubyOnRails
[00:55:16] jottr: has joined #RubyOnRails
[00:57:01] kapil___: has joined #RubyOnRails
[00:59:50] sevenseacat: has joined #RubyOnRails
[01:00:09] budfox: I've been away from the Rails scene for a good year or so now. Has there been any important new developments since the release of 5.0?
[01:01:26] budfox: (spent a lot of time in the cryptocurrency scene as a matter of fact -- and I'm amazed at how secretive and hostile everyone is there compared to places like this)
[01:04:32] jottr: has joined #RubyOnRails
[01:09:28] timdotrb: has joined #RubyOnRails
[01:09:53] timdotrb: Evening, all
[01:11:25] cagomez: has joined #RubyOnRails
[01:14:19] cagomez: has joined #RubyOnRails
[01:23:26] timdotrb: I’m using paperclip to store images, and added papercrop so the user can crop their image. Everything is working as expected locally, but cropping in production, the image doesn’t get updated. I’m guessing because the timestamp doesn’t update, so the browser doesn’t know there’s a new asset for it to retrieve and it displays the cached image
[01:23:39] timdotrb: Is there a way to force that timestamp to update after the image gets cropped?
[01:33:16] budfox: has left #RubyOnRails: ()
[01:38:13] daemonwrangler: has joined #RubyOnRails
[01:48:03] segy: has joined #RubyOnRails
[01:51:13] jottr: has joined #RubyOnRails
[01:57:18] cagomez: has joined #RubyOnRails
[01:57:43] Jameser: has joined #RubyOnRails
[02:00:17] openstruct: has joined #RubyOnRails
[02:03:23] xcesariox: has joined #RubyOnRails
[02:06:42] mtkd: has joined #RubyOnRails
[02:15:25] havenwood: timdotrb: look at #touch
[02:30:09] cagomez: has joined #RubyOnRails
[02:45:17] hahuang61: has joined #RubyOnRails
[02:45:25] jottr: has joined #RubyOnRails
[02:46:01] Saukk: has joined #RubyOnRails
[02:56:13] tcopeland: if budfox comes back - webpack was introduced in 5.1, that was pretty significant
[02:56:26] swgillespie: has left #RubyOnRails: ()
[02:58:04] cagomez: has joined #RubyOnRails
[02:58:15] hfp_work: has joined #RubyOnRails
[03:03:52] cagomez: has joined #RubyOnRails
[03:04:46] Jameser: has joined #RubyOnRails
[03:09:43] greengriminal: has joined #RubyOnRails
[03:11:29] chrickso: has joined #RubyOnRails
[03:12:34] chrickso: has left #RubyOnRails: ()
[03:17:51] timdotrb: has joined #RubyOnRails
[03:20:22] LateralOctober: has joined #RubyOnRails
[03:20:27] timdotrb: has joined #RubyOnRails
[03:21:25] timdotrb: has joined #RubyOnRails
[03:22:00] timdotrb: has joined #RubyOnRails
[03:22:53] timdotrb: has joined #RubyOnRails
[03:25:01] justrying: has joined #RubyOnRails
[03:34:03] jottr: has joined #RubyOnRails
[03:35:18] kies: has joined #RubyOnRails
[03:38:50] Cache_Money: has joined #RubyOnRails
[03:40:55] hahuang65: has joined #RubyOnRails
[03:41:17] darkhanb: has joined #RubyOnRails
[03:46:50] hfp_work: has joined #RubyOnRails
[04:00:36] KeyJoo: has joined #RubyOnRails
[04:19:02] cagomez: has joined #RubyOnRails
[04:19:50] cagomez: has joined #RubyOnRails
[04:21:04] ahrs: has joined #RubyOnRails
[04:25:14] trautwein: has joined #RubyOnRails
[04:26:20] cagomez: has joined #RubyOnRails
[04:28:04] jottr: has joined #RubyOnRails
[04:51:05] timdotrb: has joined #RubyOnRails
[04:51:23] jottr: has joined #RubyOnRails
[05:09:47] b3rnd: has joined #RubyOnRails
[05:17:33] hahuang65: has joined #RubyOnRails
[05:23:10] srruby: has joined #RubyOnRails
[05:24:29] jottr: has joined #RubyOnRails
[05:27:34] srruby: rvm wasn't initializing the ruby version when I opened a new window from within lxterminal. I solved this by putting cd . as the last line in .zshrc Not sure how I should have fixed it.
[05:32:59] kapil___: has joined #RubyOnRails
[06:00:36] Jameser: has joined #RubyOnRails
[06:03:44] Radar: srruby: a common fix would be to remove rvm entirely and to use chruby and ruby-install instead
[06:05:24] srruby: Radar: Thanks
[06:09:08] jottr: has joined #RubyOnRails
[06:32:59] someish: has joined #RubyOnRails
[06:34:44] cschneid: has joined #RubyOnRails
[06:48:43] dionysus69: has joined #RubyOnRails
[06:52:36] orbyt_: has joined #RubyOnRails
[07:00:54] fragamus: has joined #RubyOnRails
[07:02:06] srinidhi: has joined #RubyOnRails
[07:03:14] jottr: has joined #RubyOnRails
[07:09:32] fragamus: has joined #RubyOnRails
[07:16:44] darkhanb: has joined #RubyOnRails
[07:20:04] nickjj_: has joined #RubyOnRails
[07:20:25] LateralOctober: has joined #RubyOnRails
[07:20:33] darkhanb: has joined #RubyOnRails
[07:28:16] conta: has joined #RubyOnRails
[07:32:13] jottr: has joined #RubyOnRails
[07:49:20] dminuoso: Radar: dont let matthew hear that :p
[08:00:11] jottr: has joined #RubyOnRails
[08:04:49] gambl0re: has joined #RubyOnRails
[08:11:31] b3rnd: has joined #RubyOnRails
[08:17:01] lipoqil: has joined #RubyOnRails
[08:17:52] pfg: has joined #RubyOnRails
[08:18:08] craysiii: has joined #RubyOnRails
[08:23:58] srinidhi: has joined #RubyOnRails
[08:24:46] schneide_: has joined #RubyOnRails
[08:26:52] schneide_: has joined #RubyOnRails
[08:35:31] Dimik: has joined #RubyOnRails
[08:54:11] jottr: has joined #RubyOnRails
[08:56:48] marr: has joined #RubyOnRails
[08:59:19] DrYockel: has joined #RubyOnRails
[09:03:32] b3rnd: has joined #RubyOnRails
[09:03:32] mikecmpbll: has joined #RubyOnRails
[09:05:47] srinidhi: has joined #RubyOnRails
[09:12:09] b3rnd: has joined #RubyOnRails
[09:17:48] Andr3as: morning everyone
[09:17:59] Andr3as: guess what, i am stuck.. ;)
[09:18:18] Andr3as: anyone ever tried to use a view helper method in a mailer template?
[09:18:26] Andr3as: like number_to_currency
[09:19:05] Andr3as: it doesnt work out of the box.. any advise? i googled the for some time now but no luck
[09:19:53] mtkd: has joined #RubyOnRails
[09:27:52] apeiros: has joined #RubyOnRails
[09:31:35] LateralOctober: has joined #RubyOnRails
[09:35:03] srinidhi: has joined #RubyOnRails
[09:44:45] xcesariox: has joined #RubyOnRails
[09:45:05] Kilo`byte: has joined #RubyOnRails
[09:46:36] srinidhi: has joined #RubyOnRails
[09:48:13] jottr: has joined #RubyOnRails
[09:50:13] damonf: has joined #RubyOnRails
[09:50:28] dminuoso: Andr3as: I have some advice.
[09:50:33] dminuoso: Andr3as: Ditch ActionView.
[09:51:01] dminuoso: And live happily ever after. No more "magic stuff". No longer is "render" some sideeffectful non-composable thing. No longer are views magical.
[09:51:16] dminuoso: No more global helpers making stuff magically work or magically not work.
[09:51:34] defsdoor: has joined #RubyOnRails
[09:52:03] Terens: has joined #RubyOnRails
[09:52:49] Andr3as: maybe later, i just needed a dollar sign and got that sorted without the helper
[09:53:04] Andr3as: i wont completely get rid of my views for a dollar sign
[09:53:29] Andr3as: but thanks for the tip, looks like an interesting concept
[09:53:39] Kilo`byte: has joined #RubyOnRails
[09:54:49] Terens: Hello. Lets say I have two models. ModelA ModelB . ModelA has a user_id . ModelA has many ModelB. So if I let user edit/update ModelA form with ability to crud nested ModelB how can I prevent him from assigning ModelB ids that don't belong to to ModelA thus to him or are new ?
[09:58:49] Kilo`byte: has joined #RubyOnRails
[10:01:48] arBmind: has joined #RubyOnRails
[10:09:00] dminuoso: terens: what about a simple.. if statement?
[10:09:12] dminuoso: Or if you are using pundit, you could do this trivially from there.
[10:10:33] tbuehlmann: or some kind of validation if you're using accepts_nested_attributes_for and fields_for (where a simple if is not so simple)
[10:11:47] jottr: has joined #RubyOnRails
[10:14:49] cschneid: has joined #RubyOnRails
[10:20:23] dminuoso: tbuehlmann: Why would it not be simple?
[10:21:36] dminuoso: tbuehlmann: It seems to be a railism to "pump params into models unchecked, and then demand some magic dsl to do some very specific checking". The solution is to not pump params into models unchecked.
[10:21:39] Terens: I have tons of models so maybe a solution with pundit would be ok
[10:21:47] dminuoso: terens: Do you already use pundit?
[10:22:00] Terens: yes but for limited things
[10:22:25] Terens: no experience with pundit so I left it for later
[10:22:48] dminuoso: terens: Is it a permission thing, or a validation thing?
[10:22:56] workmad3: has joined #RubyOnRails
[10:22:57] Terens: Permission
[10:23:51] Terens: The problem is that ModelB in my previous example doesnt have a user_id directly but modela_id
[10:24:01] dminuoso: terens: then definitely do this in pundit. Create a simple policy that accepts a pair [modelA, modelBs], and then just do something like: return true if user.has_role? :god; return modelB.ids.uniq == [modelA.id]
[10:25:03] Terens: needs some testing though
[10:27:42] dminuoso: terens: the beauty of pundit is that, given some abstract "resource" (in this case a pair of some things), and some abstract "user" you can define a set of "interactions". But it's extremely trivial.
[10:31:45] dminuoso: The only magic is how pundit infers the policy name. Beyond that you could think of `authorize` of as this: def authorize(scope, action); some_klass = find_policy(scope); raise Pundit::NotAuthorizedError" unless some_klass.new(current_user, scope).send(action)
[10:33:13] tbuehlmann: dminuoso: nobody is pumping unchecked params into models, that isn't even possible. I'm talking about manually changing ids in the html form, then going into the accepts_nested_attributes_for's update method
[10:35:34] srinidhi: has joined #RubyOnRails
[10:35:37] tbuehlmann: checking that kind of permission is not really possible using pundit and the default accepts_nested_attributes_for method. it's however possible with a custom method, granted that
[10:37:44] lxsameer: has joined #RubyOnRails
[10:43:36] b3rnd: has joined #RubyOnRails
[10:44:02] roshanavand: has joined #RubyOnRails
[10:44:26] roshanavand: how to output raw sql from an active record query?
[10:44:45] roshanavand: User.last.to_sql doesn't work (undefined method)
[10:45:49] tbuehlmann: .last already executes the query, it's not a relation on which you could call to_sql
[10:48:09] b3rnd: has joined #RubyOnRails
[10:53:19] roshanavand: tbuehlmann: so how should I call .to_sql?
[10:54:44] apparition: has joined #RubyOnRails
[10:56:25] dminuoso: roshanavand: User.order(User.arel_attribute(User.primary_key)).limit(1)
[10:56:37] tbuehlmann: you'd have to follow the method calls
[10:57:45] tbuehlmann: yeah, that looks close to what happens
[11:04:27] tbuehlmann: if I'm correct, the method trail should be User.limit(nil).order!(User.arel_attribute(User.primary_key)).reverse_order!.limit(1).to_sql
[11:04:44] dminuoso: tbuehlmann: is that the implementation of find_last?
[11:06:34] tbuehlmann: that's the path of User.first (== User.all.first)
[11:16:06] roshanavand: has joined #RubyOnRails
[11:24:33] mtkd: has joined #RubyOnRails
[11:29:24] roshanavand: has joined #RubyOnRails
[11:32:38] _ritchie_: has joined #RubyOnRails
[11:44:00] schneide_: has joined #RubyOnRails
[11:51:21] cschneid: has joined #RubyOnRails
[11:53:26] schneide_: has joined #RubyOnRails
[11:58:57] b3rnd: has joined #RubyOnRails
[11:59:14] b3rnd: has joined #RubyOnRails
[12:01:45] _aiguuu_: has joined #RubyOnRails
[12:09:30] volix: has joined #RubyOnRails
[12:13:18] Jameser: has joined #RubyOnRails
[12:13:39] gauravgoyal: has joined #RubyOnRails
[12:14:52] Jameser: has joined #RubyOnRails
[12:53:53] DaniG2k: has joined #RubyOnRails
[12:53:58] DaniG2k: hello all. I am posting a form with images with Dropzone. I've almost gotten everything to work, the controller is receiving the images and input fields. Only one last thing isn't working. I've posted my question in full on SO
[12:54:03] DaniG2k: https://stackoverflow.com/questions/48684017/rails-5-allow-javascript-posted-image-from-controller
[12:54:20] DaniG2k: if anyone could help it would be wicked
[12:54:33] b3rnd: has joined #RubyOnRails
[12:55:26] dminuoso: DaniG2k: Read the documentation of carrierwave.
[12:57:25] dminuoso: When you do @listing.pictures = params[:file], something bizarre happens.
[12:57:44] dminuoso: First you declare that pictures if of type Picture (which is a model!), but you assign some weird ActionDispatch::Http::UploadedFile object.
[12:58:00] dminuoso: There's no way for Ruby or Rails to know how a ActionDispatch::Http::UploadedFile can be turned into a Picture.
[12:58:37] dminuoso: DaniG2k: It's the mounted uploader that knows how to do this.
[12:59:30] DaniG2k: dminuoso: actually it's Dropzone which is sending across the image
[12:59:30] dminuoso: DaniG2k: i.e. when you do `mount_uploaders :blah, SomeClass` it creates a blah= method, that takes its argument and uses SomeClass to do *magic*
[12:59:48] DaniG2k: so i think dropzone sends ActionDispatch::Http::UploadedFile
[12:59:53] dminuoso: DaniG2k: No you miss the point.
[13:00:05] dminuoso: DaniG2k: Lets look at it from bottom up.
[13:00:17] dminuoso: DaniG2k: ActionDispatch::Http::UploadedFile is some thing representing the uploaded file.
[13:00:47] Sylario: has joined #RubyOnRails
[13:01:55] dminuoso: DaniG2k: Okay. Listing has_many :pictures. some_listing.pictures= now expects something that can be readily turned into Picture objects.
[13:02:21] dminuoso: DaniG2k: But you cant turn that "uploaded file" into a picture object implicitly. You have to create that Picture object first.
[13:02:47] DaniG2k: so I guess my question is how can I convert ActionDispatch::Http::UploadedFile into a Picture
[13:02:59] dminuoso: DaniG2k: carrierwave gives you a method for that.
[13:03:08] dminuoso: DaniG2k: it generates it with mount_uploader
[13:03:17] dminuoso: DaniG2k: that method is then called :image= and is a method in Picture.
[13:03:42] dminuoso: that method knows how to turn ActionDispatch::Http::UploadedFile into something serializeable, and then write it do the database.
[13:04:08] DaniG2k: hmm but if I try, for example, Picture.new image: params[:file].values.first
[13:04:24] DaniG2k: I get an empty Picture object
[13:05:00] DaniG2k: <Picture:0x00007faddd806d70 id: nil, created_at: nil, updated_at: nil, image: nil, description: nil, imageable_type: nil, imageable_id: nil>
[13:05:33] dminuoso: DaniG2k: try probing yourNewPicture.image
[13:05:50] dminuoso: DaniG2k: Or save it first. Im not 100% how carrierwave works.
[13:06:35] DaniG2k: ok I'll try
[13:08:35] DaniG2k: that worked
[13:08:36] DaniG2k: thanks so much
[13:08:49] DaniG2k: It doesn't actually put anything inside the picture until you save
[13:10:03] dminuoso: DaniG2k: It kind of makes sense.
[13:10:47] greengriminal: has joined #RubyOnRails
[13:11:40] dminuoso: DaniG2k: If you picked say S3, it shouldn't make this happen unless you actually saved.
[13:11:40] DaniG2k: dminuoso: thank you~!! I appreciate it
[13:11:56] DaniG2k: also, is this any less secure than making it go through rails' strong params?
[13:12:08] dminuoso: DaniG2k: strong params is just for blind mass assignment.
[13:12:23] dminuoso: DaniG2k: or blindly passing params into the rails world.
[13:12:27] dminuoso: if you explicitly pick params, there's no need.
[13:12:36] dminuoso: (unless a type confusion could cause behavioral changes)
[13:19:26] LateralOctober: has joined #RubyOnRails
[13:22:37] JDeen: has joined #RubyOnRails
[13:24:17] JDeen: In Rails 3, how can I do a X-Frame-Options = 'DENY'? I tried `config.action_dispatch.default_headers['X-Frame-Options]` but seems `config.action_dispatch` is nil
[13:25:11] dminuoso: jdeen: In 3 you definitely need some custom middleware to do this
[13:25:32] dminuoso: Dont think there's a cool way to set cors headers, unless you hack some filter in your top most controller
[13:26:33] dminuoso: jdeen: So you could do some `before_action :do_cors_magic; private def do_cors_magic; response.headers.#### end`
[13:26:43] dminuoso: And I write #### because I have no idea what API is used there.
[13:27:46] JDeen: dminuoso: after some searches, i was worried it would be not so straight forward. A filtr might be easy I suppose than a middleware. Thanks friend. I will have a look.
[13:29:27] dminuoso: jdeen: Even a middleware is really simple.
[13:29:47] mtkd: has joined #RubyOnRails
[13:29:56] dminuoso: jdeen: If you dont know how to write one, I highly recommend you do. It gives you very useful insights in how rails works. =)
[13:35:33] b3rnd: has joined #RubyOnRails
[13:42:31] p8m: has joined #RubyOnRails
[13:47:52] gauravgoyal: has joined #RubyOnRails
[13:48:04] gauravgoyal: has joined #RubyOnRails
[14:01:05] dminuoso: tbuehlmann: Preferred method of keeping information for tooltips?
[14:01:20] dminuoso: Throw it into i18n for maximum brutality, even though I dont need localization?
[14:02:19] b3rnd: has joined #RubyOnRails
[14:25:28] tbuehlmann: dminuoso: i18n sounds good
[14:31:20] schneide_: has joined #RubyOnRails
[14:32:15] schneide_: has joined #RubyOnRails
[14:34:59] rikkipitt: has joined #RubyOnRails
[14:35:59] rikkipitt: hey folks, is it possible to extend this `@event.sessions.group_by { |s| s.start_time.beginning_of_hour }` to group by day, THEN hour and return a nested object with the results correctly organised?
[14:36:06] rikkipitt: @event.sessions.group_by { |s| s.start_time.beginning_of_hour }
[14:37:59] roshanavand: has joined #RubyOnRails
[14:41:07] dminuoso: rikkipitt: use .map ?
[14:41:32] cschneid: has joined #RubyOnRails
[14:42:32] dminuoso: rikkipitt: If you are on 2.4 you can also use #transform_values to avoid .map { ... }.to_h
[14:43:45] rikkipitt: thanks dminuoso
[14:44:24] dminuoso: rikkipitt: For extra points, write them as separate lambdas for conciseness.
[14:44:46] dminuoso: rikkipitt: event.sessions.group_by(&day).transform_values(&group_by_hour)
[14:44:54] dminuoso: This reads quite nicely =)
[14:45:08] markit: has joined #RubyOnRails
[14:45:33] rikkipitt: it does indeed, but how can i relate it back to the start_date field?
[14:45:53] rikkipitt: that's why i'm currently using a block for the group_by
[14:46:02] dminuoso: rikkipitt: a block is the same as a lambda basically.
[14:46:46] dminuoso: rikkipitt: group_by_hour = -> (s) { s.start_time.beginning_of_hour }
[14:47:25] rikkipitt: ah done on session I assume
[14:47:28] rikkipitt: cool, thanks
[14:47:36] dminuoso: rikkipitt: Strictly for any _s_ that responds to start_time =)
[14:48:14] apparition: has joined #RubyOnRails
[14:48:26] dminuoso: rikkipitt: That trick to writing blocks out of line tends to create more readable code, and it lets you reason about code more easily in isolation.
[14:48:37] dminuoso: Also it makes testing small parts a lot easier, since you can simply call a lambda.
[14:48:57] rikkipitt: perfect, thanks for the tip
[14:50:20] rikkipitt: so where do I add the lambda dminuoso? on the session model?
[14:51:28] Criten: has joined #RubyOnRails
[14:52:16] Criten: has joined #RubyOnRails
[14:52:26] Criten: Morning everyone!
[14:54:51] Criten: Question about ActionCable... I'm looking to have some connections with one auth scheme, and some with another... and on top of that some with csrf and some without. I dont think this can be done cleany in actioncables current implementation?
[14:55:53] Criten: I was thinking it would be cool to be able to mount different routes (ws://localhost:3000/cable and ws://localhost:3000/cable_foo) and have each one of these bound to a different base connection class defined by the user
[15:01:03] jottr_: has joined #RubyOnRails
[15:01:28] dminuoso: rikkipitt: Either in a constant in the model or you just define it in the method where you use it.
[15:01:55] dminuoso: rikkipitt: I personally just define them in the method, I mean ultimately you do the same thing with a block anyway except you do it inline.
[15:02:54] dminuoso: rikkipitt: so that its some; def make_juice(fruits); to_juice = ->(apple) { apple.press! }; fruits.map &to_juice; end
[15:03:18] dminuoso: Note that the ! is not meant to mean "mutation" there.
[15:03:39] TinkerTyper: has joined #RubyOnRails
[15:04:40] rikkipitt: and to round this off, how would you then test that in isolation?
[15:05:23] Criten: expect(Apple).to recieve(:new) and return double
[15:05:24] rikkipitt: not the code, but i mean, because it's inline, it's not as reusable
[15:05:28] Criten: expect apple to receive press!?
[15:06:21] rikkipitt: Criten thanks, that's one way
[15:06:29] Criten: I mean... its the same as doing `fruits.map { |f| f.press! }` right?
[15:06:41] Criten: (sorry, i missed some context at the begining)
[15:07:06] Criten: or even.. fruits.map &:press!
[15:07:17] Criten: granted i'm sure your implementation is a little more complex
[15:09:26] jottr: has joined #RubyOnRails
[15:10:52] rikkipitt: Criten: I wasn't being mean there, sorry!
[15:11:03] gregf_: has joined #RubyOnRails
[15:11:06] Criten: Haha i know
[15:11:10] Criten: Just being vorbose, sorry
[15:11:59] rikkipitt: i went for the defined inline approach, all this to optimise the API and save messing round too much in javascript later!
[15:12:19] rikkipitt: cheers both
[15:13:35] Saukk: has joined #RubyOnRails
[15:19:08] schneide_: has joined #RubyOnRails
[15:20:26] alfiemax: has joined #RubyOnRails
[15:21:47] cschneid: has joined #RubyOnRails
[15:25:39] dminuoso: rikkipitt: If you want it testable, either put it into a method or constant.
[15:26:05] dminuoso: by method I mean a method that produces said lambda
[15:26:17] rikkipitt: dminuoso: that's probably what i'll end up doing
[15:26:26] dminuoso: def make_juice; ->(f) { f.press }; end
[15:26:53] dminuoso: rikkipitt: Personally I have opted for not using `def` anymore in many cases.
[15:27:09] dminuoso: I wrote a utility thing `defc` that produces autocurrying methods.
[15:27:38] rikkipitt: a bit like _.curry?
[15:27:48] rikkipitt: or whatever it is in underscore js
[15:28:37] ule: Hey guys.. how would you split a huge test file into multiples? I'm using Minitest
[15:28:48] dminuoso: rikkipitt: No much better.
[15:28:49] desperek: has joined #RubyOnRails
[15:28:56] dminuoso: rikkipitt: _.curry is kind of broken in so many ways.
[15:28:58] Criten: ule: is the file you're testing a huge file too? ;)
[15:29:00] ule: I know that Rails (Minitest) forces to create a test that must match a parent file
[15:29:12] ule: Criten: unfortunately yes
[15:29:14] dminuoso: rikkipitt: not even ramda has a proper curry utility.
[15:29:33] Criten: ule: might want to split it up into multiple, smaller, components?
[15:29:39] ule: I was thinking on using mixins and split both this UserController and UserControllerTest
[15:29:44] dminuoso: rikkipitt: I want introspectability as well as interacting nicely with composition.
[15:29:50] ule: Criten: thats the best solution?
[15:29:55] Criten: It's a solution
[15:30:02] dminuoso: rikkipitt: `defc :make_juice, { |f| f.press }` and you can either treat it as a lambda, or call it as a method.
[15:30:02] ule: any other solution?
[15:30:03] Criten: is all of the code in the controller?
[15:30:13] ule: Criten: yeah
[15:30:15] dminuoso: rikkipitt: if you pass no arguments, you clearly want the function behind it
[15:30:19] Criten: remember, light controllers, fat models ;)
[15:30:26] Criten: if people are still even saying that...
[15:30:46] ule: Criten: yeah.. we've been trying to split stuff here into serviceobjects, but this UserController unfortunatelly we couldn't split yet
[15:31:00] ule: its the last monster part of the code here :P
[15:31:17] Criten: I would deal with the large test file untill you fix the core problem, which seems to be a large controller action
[15:31:35] Criten: normally if you hit problems with testing there's probably a better way to write it
[15:31:49] rikkipitt: dminuoso: very cool, is it on github?
[15:32:22] Criten: ule: but I cant answer your question about minitest... we dont use it unfortunately
[15:34:36] arBmind: has joined #RubyOnRails
[15:35:25] ule: Criten: I talked with the team here
[15:35:34] ule: Criten: we are going to split this controller
[15:35:43] ule: better cleaning stuff now then never
[15:35:47] ule: thanks Criten
[15:36:17] ule: move some logic into a PRO (Pure Ruby Object
[15:37:04] npgm: has joined #RubyOnRails
[15:40:43] morfin60: has joined #RubyOnRails
[15:40:51] morfin60: how do i autoload gem models?
[15:41:00] morfin60: only Engine?
[15:41:07] dminuoso: rikkipitt: One of the main problems with ramda and lodash is that something like this does not work: (zipWith . zipWith) (+) a b
[15:41:55] dminuoso: It forces you to be fully aware of when one function is consumed. You cant blindly just go compose(zipWith, zipWith)(add, a, b) but compose(zipWith, zipWith)(add)(a,b)
[15:42:17] dminuoso: And thats highly annoying, especially when all you get is just anonymous function names when error are thrown. Which is another problem.
[15:49:02] b3rnd: has joined #RubyOnRails
[15:50:37] ule: Anyone using VIM and Ruby? Anyone by chance using this linter with Rubocop?
[15:50:38] ule: https://github.com/w0rp/ale
[15:51:10] ule: Im having some weird issues with colors, if you do use it, please pvt
[15:51:25] dminuoso: ule: rubocop is listed as supported, so clearly your question must be different.
[15:51:59] ule: dminuoso: my vim has line highlights when there is a rubocop issue while I'm edditing
[15:52:08] ule: it is awesome
[15:52:25] ule: dminuoso: do you use vim?
[15:57:10] rikkipitt: has joined #RubyOnRails
[15:58:11] Criten: LateralOctober: hmm.. I use vim, but i dont use the rubocop linter
[15:58:34] Criten: Maybe I should ;)
[16:01:46] ule: it is awesome
[16:02:07] dminuoso: ule: I dont want a linter. I want more.
[16:02:22] Criten: We used to have robocop hooked up to our CI
[16:02:29] Criten: but dropped it because it got annoying
[16:02:38] Criten: was a bit too strict for some stuff
[16:02:42] Criten: I know you can edit it
[16:03:47] ule: We don't use on CI either, we only use on dev
[16:15:52] roshanavand: has joined #RubyOnRails
[16:22:47] za1b1tsu: has joined #RubyOnRails
[16:22:55] troys: has joined #RubyOnRails
[16:23:59] za1b1tsu_: has joined #RubyOnRails
[16:24:29] za1b1tsu: has joined #RubyOnRails
[16:24:48] _ritchie_: has joined #RubyOnRails
[16:34:21] schneide_: has joined #RubyOnRails
[16:34:49] Inside: So.. I'm trying to build a record + associated record with an existing table with non-standard PK names. I can query the associations, but for some reason whenever I go to create the main association validations for the child object fail because the parent doesn't exist
[16:34:53] Inside: Every time I create and save a content the sponsorship details are created also if I leave the form fields empty. My content table has a boolean "sponsor": is there a way to save association only if sponsor == true?
[16:34:59] Inside: whoops, wrong paste
[16:35:07] Inside: https://gist.github.com/Insood/b560c13624487adc992e682f4a046ab4
[16:35:10] Inside: ^ that's the code
[16:35:29] Inside: Could not create new ticket because Calls service ticket must exist
[16:35:32] Inside: ^ that's the error
[16:39:22] cagomez: has joined #RubyOnRails
[16:44:29] uks: has joined #RubyOnRails
[16:46:19] yoones: has joined #RubyOnRails
[16:50:02] jottr: has joined #RubyOnRails
[16:57:07] Saukk: has joined #RubyOnRails
[16:59:11] yoones: Does rails perform some kind of caching when I use `define_method`? Because I'm trying to reproduce the behavior of decent_exposure but end up with SQL SELECT not being performed when I reload my index page
[16:59:20] Saukk: has joined #RubyOnRails
[17:00:06] yoones: I'm talking about caching when I reload a page (two seperate HTTP request, not within the same one)
[17:00:23] fryguy: yoones: share some code
[17:00:54] yoones: ok one sec
[17:06:24] schneide_: has joined #RubyOnRails
[17:08:14] Inside: so apparently my whole issue was with the way the database was setup.
[17:09:52] yoones: @fryguy, https://github.com/yoones/exposed
[17:10:01] Inside: I use SQL Server import/export wizard to copy production data to the dev environment then ran a script to add some PK/indices, then noticed the PK column didn't have an identity - so used a suggested answer from Stack Overflow using ALERT TABLE + SWITCH... which added the identity to the column, but didn't copy the indices..
[17:10:16] yoones: look at lib/exposed.rb and both controllers (app and categories)
[17:10:23] Inside: And then the whole mess with the identity seed being set incorrectly :|
[17:11:07] yoones: to reproduce the bug: run seeds, go to categories index -> select one, edit name -> go back to index : old name remains. Restart server and new name appears
[17:14:25] Inside: none of what I said was the root cause
[17:14:33] Inside: turns out I just needed to add optional: true to the belongs_to
[17:22:50] glassresistor: has joined #RubyOnRails
[17:28:40] darkhanb: has joined #RubyOnRails
[17:28:43] guacamole: has joined #RubyOnRails
[17:28:59] guacamole: is there a rails setting i can implement to not use local storage in dev environment?
[17:31:41] Criten: quiller: local storage for what?
[17:31:44] tcopeland: anyone used https://github.com/nathanvda/cocoon ? seems pretty complete, just wondering about experiences anyone’s had
[17:32:08] Criten: file storage? or are you talking about browser localstorage?
[17:32:11] tcopeland: ACTION reads https://www.sitepoint.com/better-nested-attributes-in-rails-with-the-cocoon-gem/
[17:32:53] schneide_: has joined #RubyOnRails
[17:33:45] Kilo`byte: has joined #RubyOnRails
[17:34:52] mtkd: has joined #RubyOnRails
[17:37:58] Dimik: has joined #RubyOnRails
[17:39:35] Criten: guacamole: are you talking about for cookie?... Need more context here :)
[17:40:23] Criten: I dont think rails touches LocalStorage by default?
[17:40:42] dminuoso: Criten: It does not.
[17:40:50] dminuoso: Criten: The default storage system for session is CookieStore.
[17:41:04] Criten: dminuoso: yeah, that's what I thought
[17:41:13] dminuoso: Since.. Rails 2 I think?
[17:41:27] Criten: not sure what guacamole is asking :)
[17:41:33] guacamole: neither am i
[17:41:38] Criten: haha nice
[17:41:38] guacamole: this is someone else's implementation lol
[17:41:41] helpa: It seems like you are asking for a specific solution to a problem, instead of asking about your problem. This often leads to bad solutions and increases frustration for you and those trying to help you. More: http://meta.stackexchange.com/a/66378
[17:41:46] dminuoso: guacamole: Start with the problem you are experiencing.
[17:41:56] dminuoso: Not a question locked into some solution you are trying.
[17:42:05] guacamole: i understand how to use the channel, i'm sorry i asked a subpar questions
[17:50:34] one_zero: has joined #RubyOnRails
[17:51:43] dviola: has joined #RubyOnRails
[17:52:18] guacamole: the problem i am experiencing is that my data is not as expected when i run localhost. this is caused by a teammate using browser storage in their implementation. I am wondering if there is a way to not do this in the dev environment, other than wrapping the offending code in an unless Rails.env.dev?
[17:53:13] alfiemax: has joined #RubyOnRails
[17:54:08] Terens: has joined #RubyOnRails
[18:01:39] marr: has joined #RubyOnRails
[18:04:31] Cache_Money: has joined #RubyOnRails
[18:06:23] orbyt_: has joined #RubyOnRails
[18:07:06] Criten: guacamole: yeah, you'll have to handle that case yourself (somehow using Rails.env.dev)
[18:07:44] Criten: guacamole: I assume all this code in in javascript, you could set a global javascript variable in your layout specifing the environment
[18:08:07] guacamole: thanks Criten! i did find out its in our react component, which is probably why my quesiton was terrible... i was told it was in our rails stuff
[18:08:22] Criten: Yeah.. doesn't really have much to do with rails
[18:08:27] guacamole: yeah, sorry
[18:08:31] Criten: Its all good :)
[18:08:35] guacamole: thanks for your help anyways
[18:08:40] Criten: Happy to help
[18:20:10] roshanavand: has joined #RubyOnRails
[18:20:37] schneide_: has joined #RubyOnRails
[18:27:15] schneide_: has joined #RubyOnRails
[18:37:28] fcser__: has joined #RubyOnRails
[18:39:50] reber: has joined #RubyOnRails
[18:45:36] dionysus69: has joined #RubyOnRails
[18:45:52] alfiemax_: has joined #RubyOnRails
[18:48:28] conta: has joined #RubyOnRails
[18:49:31] fragamus: has joined #RubyOnRails
[18:49:50] alfiemax: has joined #RubyOnRails
[19:01:23] rwb-averon: has joined #RubyOnRails
[19:01:32] rwb-averon: hello -- I am receiving the following error: PG::InvalidColumnReference: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list
[19:02:03] rwb-averon: I have a many-to-many relationship where the join table includes an 'ordinal' attribute that is used to order
[19:02:59] rwb-averon: however, I have a single object that has many objects through this many-to-many relation, and I would like the resultant fetched set to be uniq
[19:03:45] rwb-averon: is it possible to have a block of code execute after the database query?
[19:03:59] rwb-averon: defined in the same place that you define 'has_many' in the model?
[19:04:20] Kilo`byte: has joined #RubyOnRails
[19:04:48] alfiemax: has joined #RubyOnRails
[19:05:01] rwb-averon: for example:
[19:05:02] rwb-averon: has_many :user_onboarding_flows, class_name: 'Onboarding::UserOnboardingFlow'
[19:05:05] rwb-averon: has_many :user_onboarding_flow_steps, class_name: 'Onboarding::UserOnboardingFlowStep', through: :user_onboarding_flows
[19:05:08] rwb-averon: has_many :user_onboarding_steps, lambda { distinct }, class_name: 'Onboarding::UserOnboardingStep', through: :user_onboarding_flow_steps
[19:05:11] rwb-averon: has_many :onboarding_steps, class_name: 'Onboarding::OnboardingStep', through: :user_onboarding_steps
[19:05:53] rwb-averon: where 'user_onboarding_flow_steps' contain the 'ordinal' attribute
[19:08:41] rwb-averon: basically -- I'd like to call 'Array#uniq' on the returned collection, regardless of it is 'onboarding_steps' or 'user_onboarding_steps'
[19:09:05] schneide_: has joined #RubyOnRails
[19:09:07] rwb-averon: without the caller needing to `.uniq` the collection themselves
[19:12:46] alfiemax: has joined #RubyOnRails
[19:17:11] mikecmpbll: has joined #RubyOnRails
[19:19:38] TinkerTyper: has joined #RubyOnRails
[19:21:46] _aiguuu_: has joined #RubyOnRails
[19:23:35] Jameser: has joined #RubyOnRails
[19:24:16] Kilo`byte: has joined #RubyOnRails
[19:24:40] cagomez: If I have an object with several ivars. I want to_json to return k,v pairs from the ivars that are not null. how do I do this?
[19:26:36] sameerynho: has joined #RubyOnRails
[19:27:02] craysiii: has joined #RubyOnRails
[19:27:36] mmun: has joined #RubyOnRails
[19:29:02] apeiros_: has joined #RubyOnRails
[19:30:04] dnyy: has joined #RubyOnRails
[19:30:58] cardoni: has joined #RubyOnRails
[19:33:14] jnollette: has joined #RubyOnRails
[19:33:15] zigzig: has joined #RubyOnRails
[19:33:52] marr: has joined #RubyOnRails
[19:34:36] safetypin: has joined #RubyOnRails
[19:35:37] kies: has joined #RubyOnRails
[19:35:41] safetypin: has anyone seen an error like this in controller testing when upgrading from rails 4.x to 5.1? No route matches {:action=>"/users/762146111", :controller=>"users", :user=>{:name=>"Michael Admin", :email=>"michael@example.com"}}
[19:39:52] fryguy: looks like a pretty straightforward error
[19:40:35] Puffball: has joined #RubyOnRails
[19:41:04] safetypin: fryguy: but why does the action key contain a path instead of the name of a method?
[19:41:57] fryguy: well, what code generates the link?
[19:42:28] za1b1tsu: what gem for mongodb is prefered?
[19:43:04] safetypin: https://pastebin.com/GKxVpbkN
[19:43:20] safetypin: fryguy: line #2
[19:43:32] Criten: are you using devise?
[19:43:41] safetypin: Criten: me? no.
[19:43:47] Criten: err, what's the line that adds that route
[19:43:57] fryguy: safetypin: ok and what does the route look like
[19:44:27] safetypin: https://pastebin.com/yn5TyJXT
[19:44:42] safetypin: that's the output of rails routes
[19:44:44] safetypin: or part of it
[19:45:01] alfiemax: has joined #RubyOnRails
[19:45:12] fryguy: and if you put user_path(@user.id) ?
[19:45:19] safetypin: https://pastebin.com/G9Vs4wVr
[19:47:12] Criten: Huh weird
[19:47:20] Criten: what does user_path(@user) return?
[19:47:25] safetypin: fryguy: *** ActionController::UrlGenerationError Exception: No route matches {:action=>"/users/762146111", :controller=>"users"}
[19:47:34] Criten: this is in a test
[19:47:37] safetypin: user_path is returning the correct path
[19:47:45] Criten: you need to do
[19:47:48] Criten: patch :update
[19:47:50] safetypin: it's like i'm using the wrong version of put and patch
[19:48:02] Criten: it doesnt actually use the path
[19:48:24] safetypin: but those tests work in a new rails 5 app that i just created..
[19:48:55] fryguy: trying to remember the details about the deprecation from action name to `_path` stuff
[19:49:01] fryguy: there's a gem that backfills it I think? I don't remember
[19:49:01] Criten: Yeah.... looks like that should work
[19:49:23] safetypin: i mean, i'm fine with using whatever format of calling these tests is necessary, but i get a different error using patch :update
[19:49:27] safetypin: let me change it around.
[19:50:07] Criten: I think we always specify the method name we want to test.... I'm confused now haha
[19:50:33] Criten: Yeah.. we always do stuff like this ` get :show, params: { id: create(:lan).to_param }
[19:50:52] Criten: but in the testing doc it says to use `foo_url`
[19:51:15] Criten: Are you using rspec... or?
[19:51:38] safetypin: if i use ```patch :user, params: { id: @user.id }
[19:51:55] safetypin: I get the error: ActionController::UrlGenerationError: No route matches {:action=>"user", :controller=>"users", :id=>762146111}
[19:52:04] Criten: :user is wrong
[19:52:11] Criten: you want to put in the name of the action you want to test
[19:52:52] Criten: Maybe someone else here can answer why it doesnt work using the url there.... according to the testing docs it should work
[19:53:59] safetypin: Criten: fryguy: thanks for looking at it.
[19:54:06] Criten: no problem
[19:54:29] fryguy: what test class are you inheriting from?
[19:55:13] safetypin: when i first updated this app to 5, i didn't realize there was an automated upgrade script, i think what was happening is that when i first started working with it, i hadn't run the upgrade script, and now that i've run it, the old format of tests is working again. but i had already gone thru and replaced a bunch of the old format with the new url helpers.
[19:55:22] safetypin: ActionController::TestCase
[19:55:52] safetypin: should i be using ActionDispatch::IntegrationTest instead?
[19:55:54] safetypin: i bet that's why
[19:55:57] fryguy: yah that's the old one, you gonna need to stop using that one, or else use the rails-controller-testing gem
[19:56:18] safetypin: kk. things are finally feeling like i'm not crazy anymore
[19:56:42] safetypin: i knew it was something fundamental, and just never thought about class inheritance.
[19:56:48] safetypin: the new rails app i just made is using IntegrationTest
[19:59:45] Criten: Sweet! Glad you figured it out
[20:04:43] safetypin: okay, this is probably a similar problem, I've based my user/session stuff on the rails tutorial book, but the "log_in_as(@user)" is not working as expected.
[20:05:06] safetypin: it's like the session[] array is not working.
[20:05:17] safetypin: or it's being cleared
[20:06:30] alfiemax: has joined #RubyOnRails
[20:14:01] roshanavand: has joined #RubyOnRails
[20:18:17] cagomez: has joined #RubyOnRails
[20:23:36] alfiemax: has joined #RubyOnRails
[20:35:00] Jayson_Virissimo: has joined #RubyOnRails
[20:36:41] alfiemax: has joined #RubyOnRails
[20:42:45] fragamus: has joined #RubyOnRails
[21:13:33] Radar: GOOD MORNING
[21:13:39] Criten: morning Radar
[21:13:46] Radar: hi Criten
[21:32:53] schneide_: has joined #RubyOnRails
[21:32:53] cagomez: has joined #RubyOnRails
[21:32:54] DoubleMalt: has joined #RubyOnRails
[21:33:10] orbyt_: has joined #RubyOnRails
[21:33:29] jnollette: has joined #RubyOnRails
[21:44:32] Jayson_Virissimo: has left #RubyOnRails: ()
[21:56:06] schneide_: has joined #RubyOnRails
[22:01:21] schneide_: has joined #RubyOnRails
[22:05:48] alfiemax: has joined #RubyOnRails
[22:18:03] schneide_: has joined #RubyOnRails
[22:22:40] okor: has joined #RubyOnRails
[22:25:01] okor: Hey! Im having problems with sendgrid. In development, the mail gets printed to console fine, but in production i get the following errors (timestamp removed): Completed 500 Internal Server Error in 809ms (ActiveRecord: 4.6ms),Errno::ECONNREFUSED (Connection refused - connect(2) for "localhost" port 25):, app/models/user.rb:9:in `send_birthday_mail', app/controllers/users_controller.rb:13:in `show' heres a github of my project: h
[22:25:10] okor: https://github.com/NilsKaden/fruehstartermail
[22:25:14] roshanavand: has joined #RubyOnRails
[22:26:25] okor: im using smtp, port is set to 25, username is apikey and password is the apikey string.
[22:27:05] okor: Also it is probably horrible practice to abuse my users show method to send the email :3
[22:28:26] schneide_: has joined #RubyOnRails
[22:28:34] fryguy: you need to change your smtp server to sendgrids, or run an smtp server that forwards to sendgrid locally
[22:29:30] okor: i have this in my production.rb file, that does the job, doesnt it? ActionMailer::Base.smtp_settings = { :adress => 'smtp.sendgrid.net', :port => '25', :authentication => :plain, :user_name => ENV['SENDGRID_USERNAME'], :password => ENV['SENDGRID_PASSWORD'], :domain => 'heroku.com', :enable_starttls_auto => true }
[22:30:38] gambl0re: has joined #RubyOnRails
[22:36:47] schneide_: has joined #RubyOnRails
[22:39:51] alfiemax: has joined #RubyOnRails
[22:40:25] mtkd: has joined #RubyOnRails
[22:41:48] Radar: oko_: Is your server configured to run in production?
[22:41:52] apeiros_: has joined #RubyOnRails
[22:43:54] zigzig: has joined #RubyOnRails
[22:44:19] aguestuser: has joined #RubyOnRails
[22:47:18] Radar: oko_: !rule12
[22:47:18] helpa: oko_: Do not PM members of the channel without first asking if that is OK.
[22:52:52] alfiemax: has joined #RubyOnRails
[22:54:42] okor: Radar: my bad, sorry
[22:58:33] aguestuser: has joined #RubyOnRails
[23:01:21] alfiemax: has joined #RubyOnRails
[23:08:48] acovrig: has joined #RubyOnRails
[23:12:33] jottr: has joined #RubyOnRails
[23:14:03] alfiemax: has joined #RubyOnRails
[23:16:28] fragamus: has joined #RubyOnRails
[23:20:06] srruby: has joined #RubyOnRails
[23:22:33] alfiemax: has joined #RubyOnRails
[23:23:43] jnollette: has joined #RubyOnRails
[23:25:29] aguestuser: has joined #RubyOnRails
[23:27:14] jottr: has joined #RubyOnRails
[23:28:09] jnollette: has joined #RubyOnRails
[23:28:09] zigzig: has joined #RubyOnRails
[23:29:29] _aeris_: has joined #RubyOnRails
[23:29:42] Inside: I'm still stuck with this whole created nested associations thing.
[23:29:50] Inside: Yeah, I know the problem.
[23:29:54] Inside: ACTION facepalms.
[23:30:20] apeiros_: has joined #RubyOnRails
[23:31:15] Inside: No, I don't know the problem.
[23:33:34] Inside: If I have a base record and in the same form want to create child record - and have the child record set the FK to the base record's ID... I uhh well - can't pass the base.id into the form
[23:33:46] Inside: so for some reason if I put belongs_to :base, optional: true it works
[23:34:13] Inside: (ie: child.base_id gets set)
[23:35:59] alfiemax: has joined #RubyOnRails
[23:39:01] aiguuu: has joined #RubyOnRails
[23:42:45] fragamus: has joined #RubyOnRails
[23:52:57] Radar: Inside: !rule3
[23:52:57] helpa: Inside: Clearly explain what is happening and create a Gist (http://gist.github.com), (formatted neatly please: http://bit.ly/1q75oia) of the code that is causing the problem you are encountering, as well as any useful output like stacktraces.
[23:58:14] apeiros_: has joined #RubyOnRails