#RubyOnRails - 22 July 2017
« Back 1 day Forward 1 day »
[10:10:55] rysiek|pl: I am trying to deploy a piece of software that does not have a very good deploy/install documentation
[10:12:03] rysiek|pl: I have an older version of this software running, but can't for the life of me figure out why the newer version fails at bundle exec rake assets:precompile
[10:12:22] rysiek|pl: NoMethodError: undefined method `email_regex' for ActiveModel::Validations::EmailValidator:Class
[10:13:14] rysiek|pl: lib/validators/email_validator.rb:3:class EmailValidator < ActiveModel::EachValidator
[10:13:14] rysiek|pl: vendor/bundle/ruby/2.3.0/gems/activemodel-220.127.116.11/lib/active_model/validations/validates.rb:26: # class EmailValidator < ActiveModel::EachValidator
[10:13:14] rysiek|pl: vendor/bundle/ruby/2.3.0/gems/rails-18.104.22.168/guides/source/active_record_validations.md:927:class EmailValidator < ActiveModel::EachValidator
[10:13:15] rysiek|pl: vendor/bundle/ruby/2.3.0/gems/validate_email-0.1.6/lib/validate_email.rb:8: class EmailValidator < ActiveModel::EachValidator
[10:15:11] rysiek|pl: actually, it's defined in the first and last file, mentioned in comments in the others (misgrepped things, pardon me)
[10:15:51] rysiek|pl: and also, this version of the software in question is a stable release, meaning that apparently there's a way to make this work
[10:16:17] rysiek|pl: sevenseacat: finally, the breaking change, whatever it was, occured between version 1.7.0.beta11 and 1.7.0 (stable)
[10:18:39] rysiek|pl: thing is they only support their own docker image that has postgres, sshd, redis, haproxy, and who knows what else bundled inside
[10:20:47] rysiek|pl: I can verify both files that define EmailValidator class are loaded, the "wrong" one firts, the "correct one" afterwards, before the error occurs
[10:25:58] rysiek|pl: but it seems like first, *something* loads the wront EmailValidator class; then the class in question loads the correct EmailValidator class; then it tries to load it again and fails
[10:31:08] rysiek|pl: is there a way to tell Rails how to treat situations where a class is defined in two files?
[10:53:48] rysiek|pl: huh, changing EmailValidator.email_regex to ::EmailValidator.email_regex in the relevant file seems to fix it
[12:09:33] maodun: The code automatically picks up changes to existing packs fine, it just won't recognize a new pack unless I kill the server and restart it
[12:15:34] rysiek|pl: has left #RubyOnRails: ("http://quassel-irc.org - Chat comfortably. Anywhere.")
[14:38:42] andywww: if you were going to put a decent amount of effort into learning a JS front end framework to consume your rails api, which would you choose?
[14:39:25] andywww: i’m tempted with ember because of its similarities with rails and with yehuda heading it up but angular seems an order of magnitude more popular
[14:40:11] havenwood: andywww: and don't forget about Elm! it'd quite nice, though seems to depend on one person
[14:42:40] havenwood: Elm is a different breed altogether, but quite good at catching errors at compile time!
[14:44:24] andywww: i was attracted to ember because of ember data but its not turning out to be quite what i hoped
[15:49:34] rollinDyno: Hi! I've an app currently running on production and I need to query the database to get some data stats. I ssh into the host and then run rails c, when I try to use ActiveRecord to query the models it times out. Is there a way I can disable this per query basis?
[15:53:47] havenwood: rollinDyno: It's a bit hacky, but: ActiveRecord::Base.connection.raw_connection.instance_variable_set :@read_timeout, 10_000
[15:55:23] fryguy: rollinDyno: is it timing out because it's a long query, or is it timing out and not even connecting to the database in the first place?
[15:58:47] havenwood: terens: we've never run into a problem, and bundler doesn't have a mechanism to enforce the bundler version - so we trust their semantic versions will be such
[15:59:24] havenwood: I use latest stable and so do most our devs. Those a few teeny versions behind seem fine.
[16:00:58] havenwood: terens: How would you even orchestrate exact bundler versions? That seems annoying to try to enforce.
[16:02:37] fryguy: rollinDyno: you should run this query a different way. Using activerecord to do something that returns that many results is going to be problematic
[16:03:03] Terens: He says that we must have exactly the same configuration. and that since I locked to a newer version he couldnt do bundle install.
[16:03:25] havenwood: terens: You can still bundle install if your bundler is behind. But more to the point, update bundler.
[16:03:35] Terens: I told him that it doesnt lock but said that it does and that he wasted 30 minutes
[16:04:13] jackhum: hello, i want to know what are some beginner use cases of Redis. I am reading about it here and there in lots of articles
[16:05:02] havenwood: jackhum: Redis is nice for storing things you want quick access to from memory but also a copy on disk to survive restarts.
[16:06:04] jackhum: havenwood, is redis used while running query on db or something , one time i saw one developer doing that
[16:06:16] rollinDyno: fryguy: I'm trying to look at how many rows in a table have a specific property so I can get a %
[16:08:59] havenwood: jackhum: you can do them in memory with something like SuckerPunch but Redis has the option for saving to disk as well so you lose less if you restart
[16:10:44] havenwood: Well, I'm too late, but great RailsConf talk: https://www.youtube.com/watch?v=BuDWWadCqIw
[18:45:39] cam27: Ok, this is driving me nuts.my standalone rails migrations aren’t pushing up to heroku. itkeeps saying no foreign key, even though it is there. I’ve tried migrating that version as well
[19:41:49] Terens: I want to implement something like a callback. Lets say I have class Monkey and I want to be notified when it is hungry..
[19:42:18] emers2n: Just launched my second rails project: A simple anagram finder/tool: www.autoanagram.com
[19:48:29] emers2n: Thanks havenwood. You helped me with the permutation function for a string in order to identify anagrams if you remember
[19:51:02] havenwood: terens: Or there are multiple delegator options. See Forwardable, SingleForwardable, Delegator, SimpleDelegator.
[19:52:52] havenwood: terens: Ah, you want to like intermittently check if the monkey is hungry and do a thing? Mm.
[19:54:37] havenwood: terens: https://github.com/puma/puma/blob/master/lib/puma/thread_pool.rb#L231-L305
[19:56:18] havenwood: terens: https://github.com/ruby/ruby/blob/202bbda2bf5f25343e286099140fb9282880ecba/lib/rinda/tuplespace.rb#L613-L627
[19:56:47] havenwood: terens: Is that more along the lines of what you're looking for? Or can you say more?
[20:36:09] havenwood: emers2n: http://api.rubyonrails.org/v5.1.2/classes/ActiveJob/QueueAdapters.html
[20:37:00] havenwood: emers2n: There are a bunch of options. Here are a few: Sidekiq or Resque if you do want to use Redis. Sucker Punch if you don't want to use Redis.
[20:37:39] havenwood: emers2n: Take a look at the Backend Features in the link above and see what you need.
[22:35:31] dcope: is there a built in way to run something on a background thread and continue execution to fulfill a request?
[23:08:05] havenwood: dcope: ActiveJob also has a queue adapter for Sucker Punch, which itself uses concurrent-ruby.