#RubyOnRails - 03 October 2017
« Back 1 day Forward 1 day »
[00:10:27] pwnd_nsfw: People who write projects like autumn are ass holes and kind of cool at the same time...
[00:10:45] pwnd_nsfw: Makes learning the project interesting, but annoying at the beginning because you have to learn all of these metaphors first lol
[00:52:28] rubio: Sorry to repeat my question but i was disconnected.... i need to "disable" the bundling feature of sprockets, (for js). I have set debug mode so i get every file separate in production like in development mode, but the sprockets is still bundling the JS anyway even if i don't use it. Can someone point me in the right direction?
[01:00:24] Radar: [10:28:59] <pwnd_nsfw> sleep's argument is in seconds and not ms? <- yes in Rubyland it's in seconds.
[01:01:53] pwnd_nsfw: I wish I knew more about structuring this project, but HORRAY FOR LEARNING EXPERIENCES
[01:04:07] pwnd_nsfw: I hope you're not doing the moneysqueeze with an evil laugh, thinking to yourself that I'll regret it and everything will fall through. And that eventually I'll come crawling back
[01:05:26] pwnd_nsfw: http://i0.kym-cdn.com/entries/icons/facebook/000/007/617/jew_basic.jpg actual sketch of Radar
[01:06:51] pwnd_nsfw: it's literally the only image I could come up with without taking a picture of myself doing it
[02:21:56] pwnd_nsfw: I feel I should go through one of my ruby books before I try actually working with just ruby. Definitely missing the comforts that rails provides heh.
[03:58:46] harrycs: hi all, relative noob here.. i'm trying to set up a rails app involving video upload via s3 - my initial thought was using carrierwave, but can i use that out of the box or are there more steps to adding video upload? i've tried googling but strangely I can't find much
[04:01:59] havenwood: harrycs: It might be worth taking a look at Active Storage. It wont be released with Rails until Rails 5.2 is out, but it works now with Rails 5.1.
[04:02:06] havenwood: harrycs: https://github.com/rails/rails/tree/master/activestorage#active-storage
[04:18:29] harrycs: havenwood: oh wow, that does look like it would solve a lot of issues. do you think carrierwave is necessary at all then?
[04:18:47] harrycs: havenwood: thanks so much, I really appreciate the response and patience with my dumb questions
[04:20:13] havenwood: harrycs: yeah, you don't need carrierwave - they even have all the js taken care of
[04:22:11] havenwood: harrycs: I've seen a nice use of Active Storage with S3 in a Rails 5.1 app. I'd recommend it.
[04:24:43] havenwood: I'll ask whathappens if she'll write a blog post, since she I know she uses Active Storage and is happy with it.
[04:26:03] harrycs: havenwood: do you remember what project that was? i'd love to take a look - i really am new and reading some more code before i try implementing would probably be good for me
[04:27:44] havenwood: harrycs: Sadly it's not open source. It's closed source code for a non-profit. I'm sure she'd be happy to answer questions.
[04:28:05] harrycs: havenwood: ahh sweet, well thanks for the suggestion for activestorage! really appreciate it
[06:33:04] andrewray: are there any other mvc frameworks besides rails that load files on demaned via autoload_paths, or is it just rails?
[07:57:18] solars: hi, I've got problems comparing timestamps in Rspec, especially AR Objects to the same attribute returned on an endpoint. How do you generally compare this? I noticed differences in milliseconds, formats, etc - e.g. I just tried expect(DateTime.parse(resp['result']['last_generated']).rfc2822).to eq metadata.generated_timestamp.rfc2822 but get 02 Dec vs 2 Dec
[08:25:01] dionysus69: it has let's say every 1.minute do in config/schedule.rb which isn't executing every minute
[08:25:18] dionysus69: then I found whenever cli command which prints out cron job, whats the every 1.minute do block for then?
[08:26:43] dionysus69: so the only point for this block every 1.minute do is to translate it later to cron? I thought this was itself executing
[08:27:06] dionysus69: so I was like what's the point of cron if ruby is doing the scheduled tasks, since it can, so I don't get what is the benefit of using cron
[08:28:24] dionysus69: ok that's fair enough I guess, I don't know implications of trust in scheduling business so far ^.^
[08:29:21] dionysus69: This will simply show you your schedule.rb file converted to cron syntax. doesn't say schedule file is just for translation
[08:40:50] solars: doesn't the rspec be_within matcher work with datetimes? I found it somewhere, tried in rails but expect(DateTime.parse(timestamp)).to be_within(1.minute).of timestamp says TypeError: expected numeric
[09:31:40] mauro1254: Hi folks! I'm working on a migration and I want to remove two index that are built on a common subset of fields (eg. index 1 on columns :a, :b, :c & index 2 on :a, :d). When the migration try to remove the second index it gaves an error
[09:32:26] mauro1254: I get the following error: ArgumentError: No indexes found on ckeditor_assets with the options provided.
[09:51:33] frojnd: Hi here... I got `undefined method `per' for #<Attachment::ActiveRecord_AssociationRelation` when I added '.per' on @enquiry.attachments.order(:id).per(:pagination_defaults) don't know how to solve this one
[11:38:56] frojnd: But I do have question with active admin though :p If I have a model Users and I have an attribute there user_type, how would I display only users which meets user_type == "worker" condition?
[11:39:20] frojnd: I know active admin has filter widget on the right side but then I have to manually write under user_type field
[12:34:29] AdamOnRails: anyone know why im getting this error when tryin to gem install datepicker...
[12:45:58] dionysus69: Is there a benefit to make rails production run with its stock server with an nginx as proxy ? or is it better to run nginx with passenger module? because I have experience with nginx/passenger configuration and I don't know how different would the first option be
[13:34:34] tcopeland: adamonrails: maybe check the clock on your machine to see if it’s skewed? that can cause cert validation errors
[13:57:44] machinewar: getting a template error when rendering an email template from within a mailer action. https://gist.github.com/AlexWheeler/1115b8f80d4a429044f6e37ef47c9855. it works in rails console, but not on server. any ideas?
[14:01:54] frojnd: How would I apply such filter User.where(user_type: "worker") for active admin index page without filters? The idea is that user only sees Users of type workers by default. Any help appreciated pretty please
[15:08:29] zeitchef: Hi everyone! Any particular reason this code doesn't work for preventing a layout to generate? - https://gist.github.com/zeitchef/8407c015a8d6ff1fdce3b782132594b4
[15:13:30] jtperreault: zeitchef: https://gist.github.com/jtperreault/e2f6d2747c1f0a17ccf7dfc5565b3dca
[16:07:11] hotspot: hello! can someone please help me understand this answer? https://stackoverflow.com/a/32389579
[16:09:32] deevil: can anybody here help me with something related to activerecord’s ability to delete dependent associations? I’ve got a has_and_belongs_to_many association, and need “.destroy” to use more than just the ID to delete children. I’m using database partitioning, so all queries like select, delete, etc., need to pass “client_id” in addition to the ID field. I’m finding a collection owned by a client and doing
[16:09:33] deevil: “@collection.destroy” is trying to delete the children from other models without usign the ID.
[16:12:30] hotspot: essentially, I'd like to be sure this cannot run in any other context than when the applicaton is run by 'rails runner x'
[16:13:41] tbuehlmann: it basically registers the block: https://github.com/rails/rails/blob/d1daf4c31301f5f5917b877fd63a817f5f4608ed/railties/lib/rails/railtie.rb#L142
[16:14:13] tbuehlmann: you'll have to trace what register_block_for does and how the block is later used
[16:24:44] daveomcd: I'm trying to create a search feature for my site, but I'm wanting to use "Sidekiq" to assist in making the search a background process so it doesn't bog down my entire website. I don't understand how I pass my results from the job when it completes back to my application though. Right now I have where the page refreshes my partial every 5 seconds, but how do I pass my results from my job to my page? Or do I need to write it
[16:28:23] daveomcd: deevil, is that a rails 5 only feature? this app i have is still on rails 4 for the time being
[16:31:16] deevil: daveomcd: Rails 5 sure makes it easier, but websockets can be used with Rails 4. I’m still supporting a Rails 4 app that uses the “websocket-rails” gem, but had to jump through a few hoops to get it all working properly, due to weird issues with threading and EventMachine. I ultimately went with a branch the websocket-rails author told me about. Not sure if it’s all been merged into master yet, but the branch has been t
[16:31:18] deevil: gem 'websocket-rails', github: 'moaa/websocket-rails', branch: 'threadsocket-rails'
[16:31:18] deevil: gem 'websocket-rails-js', github: 'websocket-rails/websocket-rails-js', branch: 'sub_protocols'
[16:34:15] deevil: daveomcd: no problem. If it’s not too hard to upgrade from Rails 4 to 5, ActionCable is great, and tends to just work, but I haven’t really had any issues running the sockets I linked you to. I’m using nginx/puma/rails4 for that site
[16:36:57] daveomcd: deevil, yep i want to upgrade to rails 5 but I've had 4 major features I needed to complete before starting that. And this is the last one - so I'm excited to get this one behind me so i can. I appreciate the help I'm looking into it
[16:55:19] andrewray: are there any other mvc frameworks besides rails that load files on demaned via autoload_paths, or is it just rails?
[18:08:08] mjuhl: I have an Active Record field called "archived". Is there a way to create a select scope, such that when I `render json: @item` archived: false is not shown?
[18:35:06] matthewd: masterasia: Either signed or encrypted depending on (configuration and) version, IIRC
[18:35:39] MasterAsia: matthewd, signed -> can be read, can't be tampered / encrypted -> can't be read or tampered
[18:36:17] fryguy: this is also only applicable to the session cookie, and it's configurable whether you are storing session data in the cookie or not
[19:51:22] baweaver: https://stackoverflow.com/questions/1908693/how-can-i-send-a-http-delete-request-from-browser
[19:51:31] zeitchef: I was only focused on basic authentication and wanted to keep my footprint small... guess it was a bad idea
[20:01:57] baweaver: you _could_ make a new rails app and copy-paste or try generating over your current one
[20:02:11] baweaver: depends though, if you disabled it by not including the file it's simple to turn back on
[20:28:01] orbyt_: Slightly off topic..I had an `EADDRINUSE` error due to the port being in use..I used `kill -9 [process_id]` to kill it. What is `-9` in this context? Google results have not been helpful.
[20:29:52] fryguy: kill really means "send a signal to this process" the default signal that gets sent is TERM, which is roughly equivalent to pressing ctrl-c to stop a program. you can send other signals, and kill lets you specify them either by name (like TERM, KILL) etc, or by id. the id for KILL is 9
[20:30:21] fryguy: KILL differs from TERM in that it stops the process no matter what, and will prevent the process from doing cleanup and stuff, it's uncatchable and untrappable.
[20:31:27] orbyt_: Nope, just wanted a high level overview, so thank you. This page (http://man7.org/linux/man-pages/man1/kill.1.html) also provided some good info.
[20:34:10] fryguy: one detail worth not glossing over is that you generally shouldn't send SIGKILL to a process unless you really have to, you should always try TERM first. it leads to unclean shutdowns and problems a lot
[20:34:46] fryguy: if you SIGKILL a database server, for example, you have a very high likelihood of data corruption or a very long start next time as it does data recovery
[20:35:24] fryguy: defaulting to kill -9 is a lot like defaulting to putting sudo in the front of every command. it's dangerous
[21:57:08] harrycs: Hi, I'm just getting started here. On this Index view, I'm working on formatting the table correctly based on whether a user is an admin (to change table structure slightly to display admin options correctly)
[21:58:08] harrycs: For part of this, I just need to add one line in the header.. This is the way I hacked together, does it look okay? It seems a bit strange to be forcing html as string but.. whatever: <%= '<th colspan="3"></th>'.html_safe if current_user.admin? %>
[21:58:56] harrycs: I could make a whole if block, but it seems a little over the top to turn one line into three
[22:40:34] cnk: harrycs: In general it is easier and more tasteful to do that sort of thing in a helper method rather than in your view. For something like this I would probably make a method that returns the entire header row - and do the 'if admin' part in that method
[22:43:04] harrycs: ah okay, and do you mean directly in the module in app/helpers or in a partial in the view?
[22:44:57] cnk: for example, you oculd biuld things up with content_tag or do 2 partials and decide between them in the helper
[22:46:31] cnk: whichever way you go, then a similar strategy for building the data rows for that table
[22:47:06] harrycs: Ah oh my god, I didn't even realize content_tag was a thing - which totally makes sense of course. I'll give it a shot! Thanks for the tip, I really appreciate it