#RubyOnRails - 02 May 2018
« Back 1 day Forward 1 day »
[00:06:21] Cache_Money: ^ Here are the models and my exising queries: https://gist.github.com/SuperFexy/83bf2b506b22842de890b287691e0784
[00:29:36] Cache_Money: Radar: The last query gives me the sum of all `brightcove_video_views` for both BrightcovePlayers for all months this year. I'd like to get those brightcove_video_views broken out by month
[00:33:40] Cache_Money: Radar: That worked! Before I was trying to do BrightcovePlayer.where("site_abbreviation = ?", 'se').where(brightcove_player_id: @brightcove_player_ids).joins(:monthly_brightcove_video_plays).where("year = ?", 2018).group(&:month).pluck("sum(brightcove_video_views)") but it wouldn't work. I saw in that link you provided that they just used .group('month') and now I'm good
[01:29:50] yebyen: so nginx needs to know the location of the precompiled assets and redirect any requests for assets into there
[01:30:21] yebyen: there are also modern(er) webpackerish ways to do this I guess, but I think they all involve this kind of reconfiguration of nginx
[01:32:30] yebyen: well, why would you want to see my nginx conf when there are perfectly fine blog post examples
[01:32:33] yebyen: http://vladigleba.com/blog/2014/03/27/deploying-rails-apps-part-4-configuring-nginx/
[01:33:41] Radar: blackcross: By default Rails does compile everything down into application.js and application.css.
[01:33:49] Radar: blackcross: It's so your app would only have to load two asset files, instead of multiple.
[01:34:11] Radar: Judging by the site you linked to, your webserver is setup correctly to serve assets.
[01:34:31] Radar: But judging from yoru source, you're not running the app in production env (I guess)? There's multiple JS + CSS calls in the head.
[02:03:49] yebyen: Behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. Separated they live in Bookmarksgrove right at the coast of the Semantics.
[02:05:12] yebyen: it's pretty clear this is not configured in production env because it is not a production website :D
[02:07:03] yebyen: if your dev environment is deployed from CI especially, and you want it to be nearly perfect copy of prod
[02:29:43] krainboltgreene: Okay, am I losing it or is there no way to do "has one via a join table"?
[06:14:09] blackcross: Radar, and yebyen, it is in production, i just have run as local as true to try to find how to fix the assets problem. Radar, how did you check if the routes require a password, also, what form is broken?
[06:15:57] blackcross: I ended up changing all the css/js in the <head> to use <%= asset_path 'filename.ext' %> with filename.ext also being added to the initializers/assets.rb
[06:16:04] Radar: blackcross: I assume they require a password because I am redirected back to the homepage when I try to access things like /usps_labels
[06:17:08] Radar: so yeah, if you use <%= stylesheet_link_tag "application" %> then it should Just Work™
[06:17:57] blackcross: hm, do i not need the <%= asset_path 'filename.css' %> then, since everything is compiled into <%= stylesheet_link_tag "application" %> ?
[06:18:43] Radar: It's been a while since I've worked in a Rails application that has assets within the app itself -- the apps I live in have JS assets as a separate app -- but it sounds right to me.
[06:18:49] blackcross: god, this seems like it'd be a nightmare for a UX/UI designer that didn't know rails
[06:19:42] Radar: I'm finding it nice and sunny over here in "Rails as a backend" + "React as a frontend" land.
[08:01:10] conta: hey folks, I have <%= options_from_collection_for_select(@payers, :id, :name) %> and I would like to send it to frontend, only as this string, no <html> or so. How can I do it?
[11:03:45] dionysus69: bchaddr.toLegacyAddress("bchtest:qpu4kc44lmf703yjewgr78fyqs8d74feauqm73v70g") returns
[11:05:30] dionysus69: it was minified, I beautified it and it's https://gist.github.com/webzorg/67a36ff2d8bc816febf8cbd0bfb904e1
[11:06:24] Radar: I don't understand how they get mradXr7WJ7cJxdTguqV7yYZecoBf67Nf11 from qpu4kc44lmf703yjewgr78fyqs8d74feauqm73v70g
[11:08:09] dionysus69: to be honest, I could just render new address type and then convert it to legacy, on client's frontend
[11:08:52] Radar: https://gist.github.com/webzorg/67a36ff2d8bc816febf8cbd0bfb904e1#file-bchaddr-js-L3733
[11:10:10] dionysus69: if you tell me that there are no potential security vulnerabilities, I could just run the js on client's side
[11:21:56] drale2k_: I am using ActiveStorage for file uploads via API. My "File" model is namespaced under "Loot", so it is "Loot::Files". The File model has an association (ActiveStorage) "has_many_attached :files" and everything works fine but the problem is now that since "Loot::Files" belongs_to User, i have an awkward call User.files.files ...
[11:22:20] drale2k_: any suggestion how to clean this up? Ideally i would still have the namespace but only call User.files
[12:40:38] mauro1254: Hi folks, why is collation_connection set to utf8_general_ci even if I specify collation: utf8_unicode_ci in database.yml?
[12:40:48] Terens: I don't know what is going on but precompiling assets at production server takes even an hour
[12:46:41] gheegh: ok.. so i'm missing something silly.. On ActiveStorage, Rails 5.2, how do I get the actual file from the record again? I'm attaching a spreadsheet file, and then passing the import record ID to a job.. but i can't seem to get the file itself back so I can process it.
[12:47:45] gheegh: rather, more specifically, I can't find the method that returns the path, IO object, URL or anything.. the storage is :amazon and it attaches and saves just fine it seems
[15:06:49] nzst: What's a good way to format log data in an email? I always get a messy string that's unreadable
[15:48:23] drale2k_: I need help with the following https://stackoverflow.com/questions/50138664/rails-how-to-delegate-method-to-collection
[16:12:51] Jon30: hey guys, I followed instructions to install Passenger for Apache+RVM, but I am getting this error "PassengerRuby cannot occur within htaccess files"
[16:18:56] nzst: my only guess is a permissions issue with the htaccess file, but i'm not familiar with that stack
[16:48:39] cagomez: What happens when a controller action just returns the result of `render` with no `location` param? ie does the browser stay on the same page with no redirect?
[17:11:46] ule: Anyone here using Capistrano? I have a setup with multiservers and adding a custom rake tast to "after 'deploy:finished' is actually running this task on all my servers. I just want to run this task on one server
[17:12:09] ule: Like capistrano handles migration. Anyone have any example or tip for accomplish this?
[17:17:41] nzst: seems like a unique role and a block might work https://stackoverflow.com/a/11594890
[17:19:11] ule: Added to migrations block like here: https://github.com/capistrano/rails/blob/master/lib/capistrano/tasks/migrations.rake#L22
[18:28:41] tf2ftw: I'm wondering how files uploaded by a user are made available to the other servers in the LB environment
[18:33:24] ryandv: hey, is it possible to execute raw SQL with old-school colon binds, if I don't have access to a particular inheritor of `ActiveRecord::Base`?
[18:33:47] ryandv: by colon binds I mean something like `SELECT COUNT(id) FROM foobars WHERE description LIKE ':query'`
[18:35:08] cagomez: is there a size/count method I can use on a relation that will not execute a SQL query? ie a regular Enumerable method?
[18:35:34] cagomez: just wondering if I can avoid calling .to_a on the relation before using .size on it
[18:36:35] ryandv: cagomez: how do you mean? ultimately you will have to ask the DB how many rows your query results in
[18:37:24] cagomez: someRelation.size executes a SQL query, but I have the # of objects in memory already. how do I count the objects in memory?
[18:39:37] ryandv: cagomez: I think size is intelligent enough to know when to execute a SQL query vs just counting the in-memory collection
[18:40:27] ryandv: cagomez: https://github.com/rails/rails/blob/master/activerecord/lib/active_record/relation.rb#L243
[18:42:16] ryandv: you can of course explicitly invoke `.count` or `.length` if you know you want to execute a SQL COUNT query or coerce the Relation to an Array and then call length from Enumerable
[22:21:17] big_reggie: e.g. plugins are on the top level environment object, but part of the config object in webpack
[22:21:52] big_reggie: is there a proper API documentation for webpacker, i can only find some sparse basic documentation but no real API
[23:13:35] Radar: Fun fact: when they re-wrote the Rails router between Rails 2 and Rails 3 they were going to ship it _without any documentation_
[23:13:58] Radar: Fun fact #2: when they introduced sprockets + the asset pipeline for Rails 3.1, they were going to ship it _without any documentation_
[23:16:57] Radar: big_reggie: I would suggest you file an issue on the webpacker repo to ask whatever questions you might have.
[23:17:12] Radar: Alternatively, you could muddle through it yourself and write the documentation yourself.