#RubyOnRails - 12 April 2017
« Back 1 day Forward 1 day »
[00:02:06] sevenseacat: the official guides http://guides.rubyonrails.org/ are a great place to start.
[03:24:42] dumariwutoriz: i thank matz and the ruby language for turning me into the most powerful hacker
[03:28:16] Radar: sunrunner20: ops are a little sensitive to walls of text at the moment so perhaps try to keep everything to one line?
[03:28:36] Radar: maybe "walls of text" isn't the right term there. Enter key shouldn't be used as a space bar.
[03:29:02] sunrunner20: anyway, whats the most up to date guide to getting RoR running on ubuntu server?
[03:31:24] sevenseacat: though I don't know if you'd want chruby/ruby-install for a prod box - thats not my forte
[03:34:55] sunrunner20: Just realized they were $40 each, maybe I should have work reimburse me for them
[03:35:50] sunrunner20: I just submitted an expense report for a bounty I put on getting a question answered on the IRC channel
[03:37:40] sevenseacat: oh yeah, is just my opinion, and it was many moons ago, it's likely better now
[03:39:08] sunrunner20: I told everybody get me the front end written 2 weeks before the due date and I'll take care of the rest
[03:41:02] sunrunner20: getting classes to interact like the prof wanted and validation etc is what I'm good at
[03:41:41] sunrunner20: I got points doc'd for being TOO good at my validation. TA didn't like that they couldn't be 200yrs old
[03:44:50] sunrunner20: I used to be good at apache, but it seems everything is using nginx now. so I better learn it
[04:06:03] sunrunner20: and sorry, enter as space bar again... which is in vogue right now rbenv or rvm?
[07:30:33] Terens: I initiate rails application update within app it self. My question is how can I reliably tell whether update is running , and get its status when finished/failed. (on a higher level) .
[09:26:10] pavelz: hello, I am tryuing to user ruby console but it doesn't really suspend on Ctrl-Z. seems like a severe bug
[09:57:57] Doldge: Hey, is anyone able to point me in the direction of some good guides/tutorials on getting started with Ruby/Rails?
[10:33:49] hamedtalebpoorb: `block in materialize': Could not find rake-12.0.0 in any of the sources (Bundler::GemNotFound)
[10:34:30] hamedtalebpoorb: https://gist.github.com/hamedtalebpoorb/cf4a84e87dadc3dea222f43216b86949
[10:36:09] universa1: hamedtalebpoorb: without having used rails in docker, error trace? command? ...
[10:38:04] tbuehlmann: hamedtalebpoorb: I recommend not adding the Gemfile and other files like you do. instead, use docker-compose and mount the whole directory
[10:42:16] tbuehlmann: you are entering a world of pain when ADDing Gemfile and Gemfile.lock and the the app directory in the Dockerfile
[10:43:49] dminuoso: 12:42 < tbuehlmann> you are entering a world of pain when ADDing Gemfile and Gemfile.lock and the the app directory in the Dockerfile
[10:45:06] dminuoso: tbuehlmann: All it means is that you have to rebuild the docker image every time you make changes to your Gemfile/Gemfile.lock -> that is not a world of trouble, it is just a rather trivial consequence.
[10:51:21] dminuoso: hamedtalebpoorb: The problem is basically the same as with spring. The software does not know you modified those files. Just rebuild your container from scratch (or if you're a bit experienced just from the layer above "ADD Gemfile"
[10:54:09] Takumo: Hi all, I've got a model which has a custom serializer for a postgres `box` field
[10:54:35] Takumo: however sometimes when I assign a value to that field, the created `Box` is all nil
[10:59:31] hamedtalebpoorb: <dminuoso>:i rebuild it many time after every changes but it not provide anything
[11:13:49] elsurudo: Using Rails 5.1.rc1 with Vue… does anyone have any tips on how to get babel to process vue files before they get to UglifyJS in production?
[11:17:00] elsurudo: I tried changing the “test” in the babel loader to: /(\.js|\.vue)(\.erb)?$/ but still no dice
[11:30:20] Takumo: not yet, just refactoring my struct to a plain object so I don't have monkey patched methods on it
[11:37:26] yaw: any idea why `timestamp without time zone` is the default datetime ActiveRecords' PostgreSQL adapter uses?
[11:47:49] Takumo: usually storing date/time in UTC and using code to adjust the value to display as per the user's preferences or app settings
[11:48:43] Takumo: only case I can think of where you would need to store zones against datetime fields is something like say
[11:50:24] Takumo: never seen the need to use `timestamp with time zone` myself for the reasons above... you usually just want sortable, selectable and filterable chronology
[11:51:40] matthewd: Do you know what the difference between timestamp and timestamptz is? Because neither one stores a timezone.
[11:56:49] Takumo: universa1: So I thought changing my `Box` to a plain class rather than a struct would help but now even weirder things are happening
[11:58:35] Takumo: universa1: updated https://gist.github.com/LeoAdamek/a7c477c766df6062390f6aa5b84dc930 -- now even weirder :/
[12:02:28] universa1: Takumo: yeah, it acts weirdly... have created a dummy app... i don't understand the behavior...
[12:06:09] matthewd: Takumo: http://api.rubyonrails.org/classes/ActiveRecord/Attributes/ClassMethods.html#method-i-attribute
[12:06:32] Takumo: I was using serializes only because I didn't think I could implement a custom `type`
[12:08:18] universa1: yep, but given the documentation for serialize my guess is it should be possible using serialize... ...not the recommended way, but possible, right?
[12:10:15] universa1: for me for a: b = Box.new(...); Dummy.create(box: b) --- i get the following calls: load, load, dump, load, load, load, load, dump, sql insert, load, dump, commit, load, load ;)
[12:12:01] matthewd: https://github.com/rails/rails/blob/428d47adfed8d6aa7b21aec2bf5ad890961c9de3/activerecord/lib/active_record/type/serialized.rb#L53
[12:13:00] matthewd: Not worth trying to implement some generic caching just in case it's slow, I guess
[12:13:31] matthewd: If your coder is slow, and you can't even special-case nil to make it fast, you can add more contextually-aware caching for yourself
[13:32:27] elsurudo: Turbolinks: Do a standard form POST (non-JS response… simply get a re-render), the object has a validation error. Navigate to another page via turbolinks link (no page reload). Now press browser’s “reload” button. Get warning that form will be re-submitted. Is this normal? Do I need to make _all_ my form POSTs “turbolinky” to avoid this, or is there a fix?
[13:41:07] teddysmoker: I'm having a problem with the cloudinary_gem (it's a SaaS for image / video processing). I'm using a initializer which stores the authentication details and that works well on a development environment but it fails on production. Note that if I run the rails console in production and check for the ENVs that store the auth details they are present. Any ideas?
[14:19:07] Nimzowitsch: when Rails starts up, among other controllers, it loads ControllerA because it is in app/ which is the default dir for config.autoload_path
[14:19:59] Nimzowitsch: which leads me to my question.. what happens when a controller is autoloaded?
[14:20:22] Nimzowitsch: do all methods get evaluated, and whenever a constant is encountered in one of the methods it gets evaluated as well
[14:20:50] Nimzowitsch: the reason I'm asking is because Rails fails to start and it shows that it fails in ModelA
[14:21:32] Nimzowitsch: the reason why it's failing it's obvious to me and I know how to fix it, but I wanna understand what goes on
[14:24:04] matthewd: Nimzowitsch: But the backtrace should tell you exactly which line has caused the load
[14:24:49] Nimzowitsch: fryguy: I've not been able to find that info online. Namely that index gets evaluated when autoloading a controller. If that's indeed the case then it's case solved
[14:25:42] helpa: http://gist.github.com - Put your codes online with pretty syntax highlighting and the ability to embed it into other pages.
[14:42:55] Nimzowitsch: matthewd, fryguy: after taking another look at the Rails doc on autoloading I saw that index is definitely evaluated on controllers
[14:47:08] Nimzowitsch: matthewd: http://guides.rubyonrails.org/autoloading_and_reloading_constants.html
[14:47:35] Nimzowitsch: matthewd: it does not say it explicitly but all examples use index, and there it says that: Let's see how Rails autoloads the Post constant in the PostsController above assuming the application has a Post model defined in app/models/post.rb
[14:48:12] Scient: I think one of the most retarded things ive ran into so far is rails basically blocking me from having a table named transactions
[14:49:13] Nimzowitsch: matthewd: so how else would you explain this -> Rails tries to start, it loads ControllerA then there's 0 application code in the stacktrace and then it shows up in ModelA
[14:49:36] Nimzowitsch: fryguy: seemed pretty adamant that that's indeed the case - that index is being evaluated
[14:52:27] Nimzowitsch: matthewd: so it scans a file and searches for constants, and the ones it encounters it autoloads?
[14:53:28] matthewd: It is loading app/models/model_a.rb because that file exists, without regard to whether ModelA is ever referenced anywhere
[14:54:07] Nimzowitsch: umm.. well that was my initial hypthesis, however, how do you explain that deeper in the stacktrace there's reference to require<top1> of ControllerA
[14:55:25] Nimzowitsch: Let's see how Rails autoloads the Post constant in the PostsController above assuming the application has a Post model defined in app/models/post.rb <- I think this is what's happening
[14:58:55] Nimzowitsch: matthewd: would you agree that what I'm looking for is not clearly defined in the docs at least? :)
[15:00:04] matthewd: In development, constants are autoloaded when their reference is encountered at runtime
[15:00:29] Scient: wait what, are u claiming that when a controller is autoloaded, it evaluates the actions and loads constants referenced there?
[15:02:07] Nimzowitsch: matthewd: in the prod scenario though, why am I seeing the ControllerA in the stacktrace? If that were the case, then the error would only show up in the ModelA
[15:02:22] Nimzowitsch: Scient: I am afraid I can't :/ take my word for it, I may lose my job if I did
[15:04:58] Scient: seeing the stacktrace would help me explain to you whats happening, but i understand not being able to share it
[15:05:22] Nimzowitsch: no, I wanna understand this, let me go on a name changing spree and I'll post a gist
[15:05:57] matthewd: I'm mostly confused about "it loads ControllerA then there's 0 application code in the stacktrace and then it shows up in ModelA"
[15:08:05] Nimzowitsch: so far I've traced the following call path: config.ru -> config/environment.rb (read about config.autoload_path and now I understand how ControllerA gets loaded) -> rails railties, initializable.. -> controllerA -> rails related code -> modelA
[15:10:25] matthewd: Nimzowitsch: I recommend seeking more info from your internal Rails support team / consultants, who can see what you're talking about.
[15:17:15] Nimzowitsch: Scient matthewd: https://gist.github.com/anonymous/5102b83ec602ada07b2bad7da8debf99
[15:19:56] matthewd: Is line 1 of a_controller.rb something other than `class AController < ApplicationController`?
[15:20:22] Scient: being in the same namespace also would explain why the whole namespace gets loaded on the first reference
[15:22:03] Scient: i almost feel i should retract my comments because 3.x was a fucking wild-wild west :P
[15:23:25] matthewd: https://github.com/rails/rails/blob/3-2-stable/actionpack/lib/action_controller/metal/params_wrapper.rb#L147
[15:23:45] matthewd: At the moment it's defined, FooController causes Foo to get loaded (if it exists)
[15:24:21] lzap: guys in our 4.x app we introduced ActiveRecord abstract model and now during dev reload things are going crazy, some models table_name is wrong: User.table_name => "application_records"
[15:24:54] helpa: lzap: http://gist.github.com - Put your codes online with pretty syntax highlighting and the ability to embed it into other pages.
[15:25:21] lzap: matthewd: this is the code change I introduced https://github.com/theforeman/foreman/commit/4deab2f313841e4283469ce9faafc0cdf1775720
[15:25:52] lzap: matthewd: now the weird thing - the app boots fine, operates normally until development class reload happens, then other models go crazy (some of them)
[15:26:46] Nimzowitsch: matthewd Scient thanks for your time and help. From now on I'll make sure to consult the 3.2 docs/code
[15:27:35] matthewd: Nimzowitsch: No worries. Probably best to also open conversations with a mention of your versions when you're that far behind.
[15:28:53] matthewd: lzap: Inheriting from ApplicationRecord in your migrations is rather counter to the point of defining migration-local models in the first place
[15:30:11] matthewd: Nothing I've heard of. There isn't anything else that could be defining an ApplicationRecord class elsewhere?
[15:31:01] matthewd: I don't see how it could "forget" the self.abstract_class bit, such that it goes looking for the wrong table :/
[15:33:56] matthewd: If you're not certain, maybe try renaming ApplicationRecord to something else, just as a test?
[15:49:10] matthewd: lzap: That doesn't sound right.. the point of the nested classes is that they are separate from the 'real' models
[15:55:48] lzap: matthewd: a colleague of mine hit it https://github.com/theforeman/foreman/pull/4454#pullrequestreview-32417832
[15:59:27] lzap: root cause - we are using our "global settings" model quite early in the boot process
[16:31:41] Technodrome: ruby on rails jobs are getting literally 50 applicants per job, its nuts, the market is now so saturated
[16:40:02] Technodrome: all these "bootcamp" learn to be a programmer shit creates probably 20 of those resumes
[17:34:01] Doddlin: I’m trying to use signaturepad to accept signatures on forms, any idea on how to store it? Worth storing the JSON in db or should I use PNG’s? Which is the simplest?
[19:11:11] nir0: hello guys, i'm trying to run "cap production deploy" and for some strange reason script goes out of working directory to hp/repo, runs git remote update and fails. this hp/repo is pretty dead thing. how do i find capistrano config? i searched throu files with "grep -rn repo ." still no luck
[19:19:21] rikkipitt: hey folks, i've got a query about finding records from a model by using the relationships of two belongs_to models... can anyone shed some light on how to do so please? https://gist.github.com/rikkipitt/e50e21ab7cb0834aa93e3cba8e404ded
[19:20:07] rikkipitt: Essentially, I'll have the profile and the event IDs, but how do I get the visits filtered by both these things in the most efficient way?
[19:29:23] tbuehlmann: rikkipitt: given a profile and event ids you want all visits associated to the events with that event ids and the visits belonging to the tickets?
[19:31:47] rikkipitt: i did it stepwise, did you manage to find a way to do a super fancy join or something?
[19:39:00] tbuehlmann: as a ticket has many visits and an event has many visits, yeah. but I don't know your usecase, so it's really up to you
[19:40:48] rikkipitt: i'll give it a whirl, i just need to ping in an event id somewhere in the lookup
[19:51:29] yebyen: and the two letter codes have a model with a table where they get descriptions applied
[19:52:00] yebyen: the code field on the action, and the table that stores the codes with their descriptions, have the same name "reason_code"
[19:52:35] yebyen: so i had the bright idea of adding "has_one :reason_code_obj, foreign_key: 'code', primary_key: 'reason_code', class_name: 'ReasonCode'"
[19:53:12] yebyen: now my problem is, when I change the code on one of my Action models, it actually changes the value of "code" field on the ReasonCode table
[19:54:03] yebyen: i did this so I could display a table of actions with these codes in them, and look up their descriptions with a single query using eager_load
[19:54:34] yebyen: i can just take the has_one association off, but i'm hoping there's a better way so I don't lose that property
[19:55:05] yebyen: because the debug logs are a lot neater when you don't hit a page and see it spit out 25 queries instantly before it's rendered
[20:18:26] yebyen: i don't understand why this didn't surface as an issue until i started eager_loading
[20:28:16] yebyen: aha : Is it a belongs_to or has_one association? https://apidock.com/rails/ActiveRecord/Associations/ClassMethods
[20:47:32] justAllgood: hi folks, sorry for my novice question here but, I'm looking to look for the best practice for how to add a headers, to a routing scope (sorry bout terminology if that's incorrect)