« Back to channel list

#RubyOnRails - 14 May 2018

« Back 1 day Forward 1 day »
[00:17:33] agent_white: has joined #RubyOnRails
[00:19:28] orbyt_: has joined #RubyOnRails
[01:05:55] alfiemax: has joined #RubyOnRails
[01:16:08] jottr: has joined #RubyOnRails
[01:46:00] Technodrome: has joined #RubyOnRails
[02:08:27] duderonomy: has joined #RubyOnRails
[02:08:31] psychoslave: has joined #RubyOnRails
[02:09:23] jnollette: has joined #RubyOnRails
[02:15:07] quazimodo: has joined #RubyOnRails
[02:29:24] jnollette: has joined #RubyOnRails
[02:47:01] Saukk: has joined #RubyOnRails
[03:04:37] jnollette: has joined #RubyOnRails
[03:10:44] gheegh: has joined #RubyOnRails
[03:16:44] sevenseacat: has joined #RubyOnRails
[03:17:00] jottr: has joined #RubyOnRails
[03:19:10] Radar: GOOD AFTERNOON
[03:24:08] tuskkk___: has joined #RubyOnRails
[03:31:17] kapil___: has joined #RubyOnRails
[04:15:22] reber: has joined #RubyOnRails
[04:20:53] s2013: has joined #RubyOnRails
[04:24:33] orbyt_: has joined #RubyOnRails
[04:45:17] j0bk: has joined #RubyOnRails
[05:12:08] xuyuheng: has joined #RubyOnRails
[05:13:36] conta: has joined #RubyOnRails
[05:17:51] jottr: has joined #RubyOnRails
[05:24:23] alfiemax: has joined #RubyOnRails
[05:33:15] Jameser: has joined #RubyOnRails
[05:38:27] xuyuheng: has joined #RubyOnRails
[05:51:27] Jameser: has joined #RubyOnRails
[05:58:35] blackmesa: has joined #RubyOnRails
[06:01:33] blackmesa: has joined #RubyOnRails
[06:03:31] vedu_: has joined #RubyOnRails
[06:05:04] ariejan: has joined #RubyOnRails
[06:13:13] conta: has joined #RubyOnRails
[06:37:01] apeiros_: has joined #RubyOnRails
[06:43:51] armyriad: has joined #RubyOnRails
[07:03:47] Jameser: has joined #RubyOnRails
[07:09:03] ariejan: has joined #RubyOnRails
[07:09:42] Technodrome: has joined #RubyOnRails
[07:11:58] Jameser: has joined #RubyOnRails
[07:14:04] roshanavand: has joined #RubyOnRails
[07:18:45] jottr: has joined #RubyOnRails
[07:21:11] srinidhi: has joined #RubyOnRails
[07:30:44] ikbenhet: has joined #RubyOnRails
[07:33:03] ellcs: has joined #RubyOnRails
[07:33:24] dionysus69: has joined #RubyOnRails
[07:33:33] za1b1tsu: has joined #RubyOnRails
[07:33:42] psychoslave: has joined #RubyOnRails
[07:44:35] DoubleMalt: has joined #RubyOnRails
[07:51:51] mikecmpbll: has joined #RubyOnRails
[07:57:09] Jameser: has joined #RubyOnRails
[07:57:51] Jameser: has joined #RubyOnRails
[08:01:28] marr: has joined #RubyOnRails
[08:03:05] mikecmpbll: has joined #RubyOnRails
[08:05:57] nemesit: has joined #RubyOnRails
[08:06:57] quazimodo: has joined #RubyOnRails
[08:12:44] Jameser: has joined #RubyOnRails
[08:23:10] DrYockel: has joined #RubyOnRails
[08:27:46] Jameser: has joined #RubyOnRails
[08:37:23] alfiemax: has joined #RubyOnRails
[08:45:25] ur5us: has joined #RubyOnRails
[08:48:12] ur5us: has joined #RubyOnRails
[08:56:11] shortCircuit__: has joined #RubyOnRails
[08:58:33] Torrone: has joined #RubyOnRails
[09:00:02] Torrone: hello, I'm trying to add a new date time column through a migration with a default value, code: https://hastebin.com/huretasomu.rb this gives me a sql error: [...] right syntax to use near '-06-02 12:00:00' at line 1. What am I doing wrong?
[09:00:46] ur5us: has joined #RubyOnRails
[09:00:58] roshanavand: has joined #RubyOnRails
[09:01:54] ur5us: has joined #RubyOnRails
[09:03:34] shortCircuit__: Jruby is such a pain inducer. :( I do a java_import and in rspec every time I do a expect_any_instance of it says wrong number of arguments 0 for 1 .. and then I end up just doing a double .. but that just defeats the purpose of the test. and now I don't know wether the code will actually work
[09:03:53] dionysus69: has joined #RubyOnRails
[09:06:37] tbuehlmann: Torrone: that will be unquoted and won't work. why don't you just use a string default like `default: '2018-06-02 12:00:00'`?
[09:07:02] Torrone: tbuehlmann, I tried, didn't work
[09:07:19] Torrone: solved just now, needed to be: "\"2018-06-02 12:00:00\""
[09:07:46] tbuehlmann: what RDBM are we talking about?
[09:09:44] shortCircuit__: no time zone :P
[09:09:48] lupine: shortCircuit__: ITYM any_instance is such a pain inducer :p
[09:10:01] lupine: one should generally structure code + tests such that it's unnecessary
[09:10:06] ur5us: has joined #RubyOnRails
[09:10:15] CBebop: has joined #RubyOnRails
[09:11:15] shortCircuit__: what is the better way to do the test? avoiding any_instance . changing the code structure and maybe instead of intializing a class inside a method , inject it? Although that could end up into too many injections
[09:11:58] apeiros: lupine: ITYM = I think you mean?
[09:12:24] lupine: shortCircuit__: I'm not sure there's any such thing as too many injections
[09:13:46] shortCircuit__: I meant a lot of paramters in the method. I actually haven't seen code like that, thats why I don't know if that like a normal thing or antipattern .
[09:14:37] lupine: I'd generally avoid calling <constant>.new inside a class if that constant is one I've introduced
[09:14:53] lupine: i.e., no need to inject Time or StringIO or whatever
[09:15:14] lupine: there are always exceptions, but this is a good starting strategy
[09:15:26] lupine: if your classes start to get unwieldy, make them smaller
[09:19:33] jottr: has joined #RubyOnRails
[09:20:28] cabotto: has joined #RubyOnRails
[09:27:27] dionysus69: can anyone help me understand this a lil better? I am locking a database row with Model.lock.find(id)
[09:27:58] dionysus69: but if I access that record with non lock way like Model.find(id), then I get double transaction instead of one, so it is not locked
[09:28:52] tuskkk___: Hello, new to ruby and rails, need some help here, https://bpaste.net/show/7ac6375e67bc, I need to find the friendly_server_name from the DB corresponding to the IP I get using that API call. How do I do that?
[09:28:54] dionysus69: if I do the transaction from couple of consoles, and all with locking mechanism, then it works. I thought row would be locked no matter how you access it later
[09:33:16] tbuehlmann: dionysus69: show some code
[09:35:08] dionysus69: in one console I do Wallet.transaction { Wallet.lock.find(1).withdrawals.create(amount: 0.1); sleep 3; } I just make it sleep so i have time to execute code in other consoles too
[09:35:35] dionysus69: in 2 other consoles I do Wallet.find(1).withdrawals.create(amount: 0.1)
[09:35:57] dionysus69: that way, 3 transactions get created but only 0.1 gets subtracted from the balance
[09:36:22] dionysus69: but if I use lock.find method in all three consoles, then correct amount of 0.3 gets subtracted
[09:37:21] dionysus69: lock.find + transaction block I mean
[09:38:01] dionysus69: the first snippet basically without sleep, in other consoles
[09:40:10] ur5us: has joined #RubyOnRails
[09:43:04] sidx64: has joined #RubyOnRails
[09:46:30] ariejan: has joined #RubyOnRails
[09:55:14] Radar: dionysus69: what database?
[09:57:39] dionysus69: Radar: postgres
[09:59:48] Radar: https://www.postgresql.org/docs/9.1/static/transaction-iso.html
[09:59:51] dionysus69: so I am glad I finally found a solution to double spendings and race conditions, but first of all, I don't understand why every snippet requires to have transaction block and lock and second, is that solid enough of a solution?
[09:59:53] Radar: Maybe relevant to your interests
[10:00:55] Radar: One day Google will learn to return most recent version results for sites like postgresql.org, ruby-doc.org, etc.
[10:01:31] dionysus69: haha I switched to current version :P
[10:03:32] Dbugger: has joined #RubyOnRails
[10:03:33] Radar: It _smells_ to me like a possible transaction isolation problem... but I am not 100% sure without seeing the problem myslef.
[10:03:34] Dbugger: Hello everyone
[10:03:53] Dbugger: Does anyone know how to remove Active Storage from a new Rails 5.2 project?
[10:04:52] Dbugger: I tried what this articles said (https://mikerogers.io/2018/04/13/remove-activestorage-from-rails-5-2.html) but then the command "rails routes" throws me an error
[10:06:55] conta: has joined #RubyOnRails
[10:10:20] dionysus69: ok thanks :) I'll stick with this solution for now and continue pummeling it in various ways to catch a race condition, gonna test on multiple puma workers now
[10:15:13] conta: has joined #RubyOnRails
[10:24:19] Diabolik: has joined #RubyOnRails
[10:38:52] Radar: Dbugger: what's the error?
[10:42:13] schneider: has joined #RubyOnRails
[10:56:12] DrYockel: has joined #RubyOnRails
[11:01:39] sidx64: has joined #RubyOnRails
[11:01:51] ur5us: has joined #RubyOnRails
[11:02:46] cabotto: has joined #RubyOnRails
[11:03:57] Fernando-Basso: has joined #RubyOnRails
[11:06:39] ikbenhet: has joined #RubyOnRails
[11:10:33] Dbugger: Radar, I solved it. Apparently I also had to remove from the environmental configuration the active_storage line
[11:10:48] Radar: Dbugger: It helps if you don't disappear for 30 minutes at a time.
[11:11:22] apeiros_: has joined #RubyOnRails
[11:11:28] Dbugger: Dbugger, sorry, yeah, I had an interruption that I could not ignore. Sorry about that.
[11:11:42] Dbugger: I meant, Radar
[11:11:52] Radar: Rightio. No worries.
[11:12:02] Radar: !rule0 is a good rule to remember for next time.
[11:12:02] helpa: Show rather than tell. Explaining your problem with code, stacktraces or errors is always preferred to explaining it with just text. Show us what's happening, rather than telling us. Put the code on https://gist.github.com and then give us the HTTP link to the Gist.
[11:12:09] Radar: Helps us give you an answer right away
[11:12:41] Dbugger: Yeah, it is the first time I play with 5.2, and I wasnt even sure of what Active Storage is, so I was kinda lost on what should I actually give as output
[11:12:53] conta: hey there, was there never :delete resource (only :destroy) ? Or am I wrong and it was removed at some point? I do not see it in 5.2
[11:13:26] Dbugger: But more than about the error, I was wondering if there is actual documentation about how to get started with a project without the Active Storage as a default
[11:13:40] Dbugger: But I guess it doesnt matter anymore
[11:14:15] tbuehlmann: conta: I assume you're talking about the dependent options. then yes, it's :destroy and :delete_all
[11:14:52] ikbenhet: has joined #RubyOnRails
[11:15:14] conta: tbuehlmann: I mean in controller actions. ie :new and :create, :show and :update. I believe there used to be :delete and :destroy?
[11:15:59] conta: I have resources 'expenses', only: [:new, :edit, :delete] and I dont see any delete route created
[11:17:44] tbuehlmann: oh, there's only the destroy action
[11:19:31] cabotto: has joined #RubyOnRails
[11:20:23] jottr: has joined #RubyOnRails
[11:20:35] ikbenhet: has joined #RubyOnRails
[11:21:16] Cavallari: has joined #RubyOnRails
[11:24:23] gregf_: has joined #RubyOnRails
[11:26:57] gavit: has joined #RubyOnRails
[11:27:35] gavit: how can I determine the specs of a vm required for my ror app?
[11:30:41] Ergo: has joined #RubyOnRails
[11:33:11] ikbenhet: has joined #RubyOnRails
[11:34:45] lupine: take a ridiculously overspecced machine
[11:34:47] lupine: then double it
[11:36:46] cabotto: has joined #RubyOnRails
[11:48:12] Radar: gavit: If it helps: my local application is taking up about 600-700mb of memory.
[11:48:29] Radar: gavit: I've got it running on a 2GB Digital Ocean machine, but it doesn't really do much... it has 4 users.
[11:49:09] Radar: And then you've got applications the size of what I do for my day job: running on a huge machine (64GB? 128GB? I don't remember) and something in the double digits for ocres
[11:49:18] Radar: TL;DR: it depends
[11:50:33] cabotto: has joined #RubyOnRails
[11:51:56] gheegh: has joined #RubyOnRails
[11:52:31] DrYockel: has joined #RubyOnRails
[12:09:27] nzst: has joined #RubyOnRails
[12:14:10] conta: has joined #RubyOnRails
[12:18:05] DTZUZO_: has joined #RubyOnRails
[12:19:26] sidx64: has joined #RubyOnRails
[12:20:16] mondongo: has joined #RubyOnRails
[12:22:10] cabotto: has joined #RubyOnRails
[12:24:26] gavit: Radar: I'm contemplating of going from RoR to Laravel. Php is horrible, but the resources for a RoR app seem so high in comparison.
[12:28:10] lupine: php is also much easier to deploy
[12:28:33] dionysus69: I am getting ActiveRecord::Deadlocked: PG::TRDeadlockDetected: ERROR: deadlock detected instead of waiting on database :S
[12:31:31] tbuehlmann: dionysus69: maybe advisory locks (application level mutexes) are more suited for your experience and application?
[12:32:04] dionysus69: ok I will look into that too, atm I just added with_lock block instead of transaction block
[12:32:22] dionysus69: I mean, this behavior is satisfactory for me, because only an attacker would try to execute this twice
[12:32:32] dionysus69: was just curious if this was normal
[12:33:40] tbuehlmann: I wouldn't consider deadlocks "normal" for your useres
[12:34:10] dionysus69: deadlock would never happen though, unless trying to abuse db
[12:34:37] dionysus69: i am trying to hack my own app that's why it fired up :D
[12:34:38] tbuehlmann: so you should protect against it
[12:36:05] dang`r`us: deadlock holiday ♪
[12:36:10] dionysus69: "from readme: your mutex spans hosts" nice
[12:36:38] tbuehlmann: it's a very simple application level mutex
[12:37:04] dionysus69: are you talking about this? https://github.com/ClosureTree/with_advisory_lock or is there a rails native way to do this without a gem
[12:37:38] tbuehlmann: I don't think there's something for this in rails, so I'm talking about https://github.com/ClosureTree/with_advisory_lock
[12:37:46] tbuehlmann: there's also pg_lock, but I wouldn't use it anymore
[12:37:59] dionysus69: yea it seems pretty outdated
[12:38:41] dionysus69: and thanks allot tbuehlmann!
[12:40:32] GodFather: has joined #RubyOnRails
[12:42:38] dionysus69: and what's the lock_name param in User.with_advisory_lock(lock_name) do?
[12:44:44] tbuehlmann: each advisory lock has a name, when you're trying to acquire a lock with two different database connections, only one gets the lock
[12:45:36] tbuehlmann: a lock with the same name*
[12:46:02] ariejan: has joined #RubyOnRails
[12:52:00] dionysus69: oh I see, will need to experiment with that
[12:54:36] tuskkk___: in one of my auto generated controllers, the index is rendering show.html.erb, why is that?
[12:54:50] tuskkk___: shouldn't it be index.html.erb?
[12:57:11] tbuehlmann: tuskkk___: the index action usually renders the index.html.erb template, yes
[12:59:07] tuskkk___: hmm, I guess something is wrong with the routing
[12:59:21] DrYockel: has joined #RubyOnRails
[13:04:08] mtkd: has joined #RubyOnRails
[13:07:00] psychoslave: has joined #RubyOnRails
[13:11:31] psychoslave: has joined #RubyOnRails
[13:21:17] jottr: has joined #RubyOnRails
[13:21:35] kapil___: has joined #RubyOnRails
[13:27:41] mikecmpb_: has joined #RubyOnRails
[13:33:27] roshanavand: has joined #RubyOnRails
[13:37:11] fcser__: has joined #RubyOnRails
[13:38:07] daxroc: has joined #RubyOnRails
[13:38:09] duderonomy: has joined #RubyOnRails
[13:46:39] context: tuskkk___: it will be index.html.erb. easiest place is to check log. are you infact hitting index action?
[13:46:44] NL3limin4t0r: has joined #RubyOnRails
[13:59:47] roshanavand: has joined #RubyOnRails
[14:03:16] s2013: has joined #RubyOnRails
[14:06:27] prahal: has joined #RubyOnRails
[14:07:56] prahal: has joined #RubyOnRails
[14:18:02] srinidhi: has joined #RubyOnRails
[14:18:03] GodFather: has joined #RubyOnRails
[14:23:18] apeiros__: has joined #RubyOnRails
[14:24:27] roshanavand: has joined #RubyOnRails
[14:30:39] cschneid_: has joined #RubyOnRails
[14:41:45] chouhoulis: has joined #RubyOnRails
[14:45:33] roshanavand: has joined #RubyOnRails
[14:50:01] orbyt_: has joined #RubyOnRails
[14:50:03] jottr: has joined #RubyOnRails
[14:51:38] roshanavand: has joined #RubyOnRails
[14:53:35] Ericx2x: has joined #RubyOnRails
[14:58:48] apeiros: has joined #RubyOnRails
[15:01:19] mtkd: has joined #RubyOnRails
[15:16:50] prahal: has joined #RubyOnRails
[15:18:17] mostlybadfly: has joined #RubyOnRails
[15:25:58] gheegh: has joined #RubyOnRails
[15:26:01] duderonomy: has joined #RubyOnRails
[15:30:24] tuskkk___: where is edit_article_path() defined? http://guides.rubyonrails.org/getting_started.html#creating-the-blog-application
[15:30:35] tuskkk___: how is that glued from the view?
[15:30:48] tuskkk___: Also, can we directly call methods in the model in the view?
[15:36:07] jcarl43: has joined #RubyOnRails
[15:37:52] jottr: has joined #RubyOnRails
[15:41:55] chouhoulis: has joined #RubyOnRails
[15:47:38] cagomez: has joined #RubyOnRails
[15:47:39] Fernando-Basso: has joined #RubyOnRails
[15:50:37] marr: has joined #RubyOnRails
[15:54:10] orbyt_: has joined #RubyOnRails
[15:56:06] tuskkk___: this the view part, raising an error, https://bpaste.net/show/f0a24d59c3c0
[15:59:47] [Butch]: has joined #RubyOnRails
[16:07:40] chouhoulis: has joined #RubyOnRails
[16:07:44] kapil___: i use `Apartment::Tenant.switch!('ee_guru12')` it changes all the postgresql queries tanent successfuly. but for one query i want to use public schema.
[16:09:47] dionysus69: has joined #RubyOnRails
[16:13:22] kapil___: i found answer:
[16:13:22] kapil___: Apartment::Tenant.switch('tenant_name') do
[16:16:49] conta: has joined #RubyOnRails
[16:17:27] conceivably: has joined #RubyOnRails
[16:19:11] apeiros: tuskkk___: where have you defined `add_to_rotation`?
[16:19:24] conceivably: Hi there. Is there a way to attach an already uploaded file (to S3) to a record using ActiveStorage? It seems like this should be possible, since it's somewhat similar to the direct upload situation, but the API is pretty murky, and combing through the source I'm still not sure how I would go about doing that :/
[16:19:42] tuskkk___: apeiros: in the controller, adding helper_method :add_to_rotation, solved it, is it correct?
[16:20:04] apeiros: that's how you make a controller method available in the view, yes
[16:21:23] tuskkk___: apeiros: one more question, the autogenerated view have this edit_(name)_path method, where does this come from?
[16:22:00] apeiros: the router/routing mechanism generates those methods
[16:23:06] apeiros: they are stored (maybe additionally to another place) in Rails.application.routes.url_helpers
[16:23:07] tuskkk___: apeiros: one more thing, ideas to optimize this https://bpaste.net/show/eb1026378edd please
[16:23:23] qnaal: has joined #RubyOnRails
[16:23:31] tuskkk___: is it ok to use a class as DTO in rails?
[16:23:50] tuskkk___: or should I use a hash/dictionary?
[16:24:39] apeiros: I'd move that out of the controller
[16:25:04] apeiros: `ary = []; other.each do |e| ary << f(e) end` --> `ary = other.map { |e| f(e) }`
[16:25:44] tuskkk___: yes, I am planning to move that logic to a service
[16:25:44] apeiros: the `record.resource_records.each` iteration seems weird.
[16:26:10] tuskkk___: apeiros: well, the AWS response has that sub array
[16:26:23] apeiros: is it intentional to just set the model.dns_status and model.rotation to the last entry you find where server.ip_string and address.value match?
[16:28:11] tuskkk___: apeiros: to the last entry? I am populating model for each entry and adding them to a list to render
[16:28:27] apeiros: one model per server
[16:28:38] tuskkk___: when the IP's match, values for dns_status and rotation are changed
[16:28:46] tuskkk___: apeiros: yes!
[16:28:49] apeiros: but not one model per address
[16:29:05] tuskkk___: I need it for each server
[16:29:20] apeiros: wrt address, you only care about the last one which matches the server.ip_string
[16:29:33] apeiros: or your code does. whether you do was kinda my question
[16:30:23] tuskkk___: not getting you, basically the idea is, have a list of servers in the DB, if their DNS is set in AWS route53, populate it.
[16:30:44] tuskkk___: so I query the DB first, then fire a call to AWS, and merge.
[16:30:57] tuskkk___: DB has ip_string, AWS has IP, I check there
[16:31:57] apeiros: let me ask differently: is it possible that @ip_list contains multiple entries with the same address.value in any of its resource_records?
[16:32:35] orbyt_: has joined #RubyOnRails
[16:32:55] apeiros: i.e. if you'd do `@ip_list.each do |record| record.resource_records.each do |address| puts address.value end end` could the same line appear twice?
[16:35:03] tuskkk___: apeiros: no, IPs are unique there at AWS
[16:35:20] fox_mulder_cp: hi, folks. i try to create rails isolated ngine gem with model relations: EngineName::User has many => EngineName::Session. how i can describe relations, generators for proper use it in main app?
[16:36:19] apeiros: tuskkk___: then you could avoid going through all of them for every server.
[16:36:39] tuskkk___: apeiros: hmm, really? how?
[16:36:55] apeiros: you build a lookup table. is there a reference from address to record?
[16:36:58] tuskkk___: I'd love to do that, that will make it way less complex
[16:37:23] tuskkk___: I have a table yes, it stores server names and their IP
[16:38:11] apeiros: no, I mean in the object you have stored in the `address` variable in your code. is there a reference?
[16:38:49] tuskkk___: ah, no, all that comes from the call, haven't stored that anywhere
[16:40:43] tuskkk___: also, I did, https://bpaste.net/show/c66841acf893, and https://bpaste.net/show/16fe09485479, but on clicking either of them, both are printed in the console
[16:41:05] apeiros: @ip_by_address = @ip_list.each_with_object({}) { |record, lut| record.resource_records.each do |address| lut[address.value] = record.name end }
[16:41:06] tuskkk___: I need to perform those intermediate operations from the view, just like edit and delete
[16:41:32] apeiros: then you can just use: name = @ip_by_address[server.ip_string]; if name …
[16:42:11] tuskkk___: woha, what just happend, give me a second to process that
[16:43:11] apeiros: depending on whether AWSRoute53Service.new.list_record_sets() is your code or not you could maybe even do it there already.
[16:44:21] tuskkk___: apeiros: that's from here, https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Route53/Client.html#list_resource_record_sets-instance_method
[16:44:50] tuskkk___: apeiros: please also look at my view part
[16:45:08] apeiros: got other things to do now, sorry.
[16:45:43] tuskkk___: ok, thanks a lot! Let me see if I can understand the code you gave me!
[16:45:55] tuskkk___: will google more about the view...
[17:06:42] mtkd: has joined #RubyOnRails
[17:07:48] fox_mulder_cp: oh oh. pgp/pgp && smime can be decrypted https://twitter.com/seecurity/status/995906576170053633
[17:09:39] mtkd: has joined #RubyOnRails
[17:10:38] _aeris_: has joined #RubyOnRails
[17:10:50] jnollette: has joined #RubyOnRails
[17:13:02] gheegh: has joined #RubyOnRails
[17:14:03] roshanavand: has joined #RubyOnRails
[17:18:58] gheegh: has joined #RubyOnRails
[17:19:22] za1b1tsu: has joined #RubyOnRails
[17:22:26] Puffball: has joined #RubyOnRails
[17:34:34] tuskkk___: How do we perform an operation from the view? e.g I need to do 'add_to_something(name)' from the view. Do I need a new controller for it?
[17:34:52] tuskkk___: have tried adding helper methods, they get called on /controllerName
[17:38:01] mtkd: has joined #RubyOnRails
[17:39:14] atrius: has joined #RubyOnRails
[17:40:11] LyndsySimon: has left #RubyOnRails: ()
[17:45:57] Saukk: has joined #RubyOnRails
[17:48:31] fox_mulder_cp: tuskkk___: what are you need to add? item to cart, or comment to post, or photo to profile?
[17:49:11] tuskkk___: fox_mulder_cp: server ip to its dns mapping
[17:49:46] fox_mulder_cp: you write your own DNS control web app? ^)
[17:50:31] fox_mulder_cp: tuskkk___: ahaha. do you know how DNS is worked? what dns server are you using?
[17:50:58] tuskkk___: fox_mulder_cp: yes, route53
[17:51:24] mroutis: has joined #RubyOnRails
[17:51:57] fox_mulder_cp: tuskkk___: so read api for it. by the way, long-time operations can be called from long term executed background jobs, like resque gem
[17:52:36] tuskkk___: fox_mulder_cp: I need rails specific help, like how to call an operation from a view
[17:53:12] tuskkk___: unable to get my business logic displayed in the views
[17:53:25] mroutis: what kind of "operation" are you trying to call, tuskkk___ ?
[17:53:36] fox_mulder_cp: view -> controller action like create post, after it - model actions like User.disable or User.send_email
[17:53:40] weird_error: has joined #RubyOnRails
[17:53:56] fox_mulder_cp: mroutis: it call amazon route53
[17:54:05] tuskkk___: I have a table that will list all the servers, I have delete and add operations there
[17:54:16] mroutis: ohh okok, sounds good
[17:54:27] fox_mulder_cp: tuskkk___: it's a model level operations
[17:54:39] tuskkk___: yes, but how do I trigger them from the view?!
[17:54:51] tuskkk___: do I need to create a new controller?
[17:55:04] mroutis: tuskkk___, fox_mulder_cp is right, you should call and endpoint (controller#action) using ajax
[17:55:09] tuskkk___: and does it only support create, destroy? custom names?
[17:55:26] tuskkk___: mroutis: that would be nice, example please
[17:55:30] fox_mulder_cp: tuskkk___: we don't know what are you have. your ServerController#do_some_with_Server_model
[17:55:30] mroutis: no, you can define whatever action you want, create and destroy are part of a REST convention
[17:55:48] fox_mulder_cp: tuskkk___: try to read aooficial reails guides wich creates small blog app
[17:56:06] tuskkk___: saw the blog, not very helpful
[17:56:28] fox_mulder_cp: tuskkk___: CRUD idea with MVC pattern are common
[17:56:31] tuskkk___: https://github.com/coderhs/blog right
[17:56:46] tuskkk___: I have the idea, don't know how to get it done here
[17:57:27] fox_mulder_cp: tuskkk___: replace Blog Post to your Server model, as example :)
[17:57:47] tuskkk___: here is what I have, https://bpaste.net/show/5ab55eaf83ce
[17:58:17] fox_mulder_cp: Blog post can be deleted, updated, hidden from unauthenticated users, or saved as pdf, it's a some of example controller actions
[17:58:53] fox_mulder_cp: tuskkk___: so write controller actions and add this actions to routes
[17:59:14] tuskkk___: fox_mulder_cp: did that, https://bpaste.net/show/9a761feef797
[17:59:26] tuskkk___: they all execute on /servers
[17:59:33] tuskkk___: want them to execute only when clicked
[17:59:34] fox_mulder_cp: if tasks can be executed long time - run it from resque or refault activejob
[17:59:47] fox_mulder_cp: tuskkk___: remove private keyword
[17:59:59] fox_mulder_cp: private - can be accessible only from another controller actions
[18:00:04] tuskkk___: ok, let me test it without private
[18:00:06] fox_mulder_cp: like secured params
[18:00:18] fox_mulder_cp: and add it to route list
[18:02:05] mroutis: has joined #RubyOnRails
[18:02:38] tuskkk___: fox_mulder_cp: but these methods are being called when server -> index is rendered
[18:02:43] tuskkk___: where the table is
[18:03:11] fox_mulder_cp: it shouldn't be called in index
[18:03:28] tuskkk___: the view is index.html.erb
[18:03:48] mroutis: tuskkk___: can you share a code example in `gist`?
[18:04:11] fox_mulder_cp: oh. try to reread your blog code... seems, that you have a mistake in app logic.
[18:04:45] fox_mulder_cp: i create mistakes like this ~5 years ago when can't know about crud and mvc
[18:05:40] sameerynho: has joined #RubyOnRails
[18:06:11] tuskkk___: here is the controller and index view, https://bpaste.net/show/f92aae83ae15, https://bpaste.net/show/93020129d902
[18:06:14] gheegh: has joined #RubyOnRails
[18:06:42] tuskkk___: fox_mulder_cp: seems more like a rails things to me
[18:06:51] fox_mulder_cp: use gist.github.com - it's easy and without spam and adds..
[18:07:45] tuskkk___: fox_mulder_cp: bpaste has no ads
[18:07:52] tuskkk___: or does it?
[18:08:03] fox_mulder_cp: tuskkk___ me too, but i every day learn it when write my main app and two experimental pets:0
[18:08:33] tuskkk___: ok, can you help me here in this case?
[18:09:07] mroutis: okok, tuskkk___, your code looks good, where's the problem?
[18:09:35] fox_mulder_cp: https://bpaste.net/show/f92aae83ae15 what is a shit on 12 line? use gist. im more friendly for helping and highlighting code
[18:10:04] fox_mulder_cp: helper methods - why it in controller? it's a actions
[18:10:14] fox_mulder_cp: you need route for use it
[18:10:41] tuskkk___: get 'servers/add_to_rotation'
[18:10:50] tuskkk___: was there is the routes, is that correct?
[18:11:01] tuskkk___: mroutis: going to /servers executes that code
[18:11:13] fox_mulder_cp: like post 'some_action', to: 'servers#actions'
[18:11:28] fox_mulder_cp: tuskkk___: get route - for GET data. POST - for modify
[18:11:52] fox_mulder_cp: so why you use get 'servers/add_to_rotation' ?
[18:12:18] tuskkk___: thought that would make it work
[18:13:07] tuskkk___: fox_mulder_cp: https://gist.github.com/prawadhwani/5ad291918dbdc75f9482c3162f6ace52
[18:15:53] fox_mulder_cp: tuskkk___: adopt this example for you https://gist.github.com/foxmuldercp/7e66ba882ed7398c7abed3ab5d40d5f6
[18:16:11] fox_mulder_cp: all actions buttons - by default POST data
[18:16:54] fox_mulder_cp: tuskkk___: try to reread blog example manual :)
[18:17:22] fox_mulder_cp: i reread and reexecuted it for ~5 times :)
[18:17:52] tuskkk___: I am in a hurry, just read it once
[18:18:18] tuskkk___: read this now, http://guides.rubyonrails.org/routing.html
[18:18:38] fox_mulder_cp: after c# and aspnet mvc guides. it realle intrested. sone months ago i create json only blog with reactjs web and jwt
[18:20:49] RougeR: has joined #RubyOnRails
[18:21:25] RougeR: anyone got an example of radio buttons for rails. ive ended up doing it in a html table. I want radio buttons for selecting the values 1 to 10. couldnt seem to quite fathom the docs
[18:23:53] fox_mulder_cp: RougeR: http://guides.rubyonrails.org/form_helpers.html ?
[18:25:30] KucukMubasir: has joined #RubyOnRails
[18:25:58] KucukMubasir: hi there, I have a serious problem, I need to use both bootstrap 4 and 3 in the same app. is this possible?
[18:26:47] dviola: has joined #RubyOnRails
[18:26:47] fox_mulder_cp: KucukMubasir: oh. styles and methods can be mixed and overrided, so it may be not usable
[18:27:00] RougeR: thanks fox_mulder_cp ive read that through and i could get it to work
[18:27:12] fox_mulder_cp: RougeR: you are welcome :)
[18:27:30] RougeR: i want to get it to work with a range basically
[18:28:05] fox_mulder_cp: RougeR: hm. you can use different layout and different style for some pages
[18:28:38] fox_mulder_cp: like user/profile layout with twbs3 and /posts/(:id) with twbs4
[18:29:03] RougeR: its a form_for with a rating system. not sure i follow
[18:29:18] KucukMubasir: fox_mulder_cp: don’t say that :((
[18:29:21] fox_mulder_cp: but may be you mast create dirty hacks or use twbs from CDN
[18:29:32] KucukMubasir: can’t I pick the version according to view?
[18:29:39] RougeR: ill hack around it for now n come back to it
[18:29:42] fox_mulder_cp: KucukMubasir: layout :)
[18:30:26] KucukMubasir: yeah but will I able to specify the bootstrap version with it?
[18:30:33] fox_mulder_cp: oh. i don't use internal rails erb views for a some last years :)
[18:31:01] fox_mulder_cp: KucukMubasir: import directly from cdn, or read gem docs and pin versions
[18:31:51] KucukMubasir: oh, so you are saying there is a way to use different bootstrap versions as long as they are used on different pages?
[18:32:24] fox_mulder_cp: KucukMubasir: layouts
[18:32:30] AlHafoudh: has anyone tries to add custom attribute to ActiveStorage::Blob ?
[18:32:33] KucukMubasir: thanks again fox_mulder_cp <3
[18:32:42] fox_mulder_cp: http://guides.rubyonrails.org/layouts_and_rendering.html
[18:38:32] KucukMubasir: yep, I know it. I was just worried about different gem versions on gemfile and possible conflicts that might arise; but you claim that both of them can be installed by GemFile, or should I just link them without using gemfile?
[18:40:21] tuskkk___: fox_mulder_cp: fixed the routes - https://gist.github.com/prawadhwani/5ad291918dbdc75f9482c3162f6ace52, still the same :(
[18:40:35] tuskkk___: I feel, something else is wrong
[18:55:50] ariejan: has joined #RubyOnRails
[18:59:54] tycoon177: If I wanted to find information about including some javascript in a gem to be available to the asset pipeline, where should I look for that information? I figured out how to write a rack middleware in a gem last week, but I would like to add some javascript that interfaces with it to my app automatically.
[19:01:55] srinidhi: has joined #RubyOnRails
[19:06:12] nzst: tycoon177: https://github.com/rails/sprockets
[19:07:43] dionysus69: has joined #RubyOnRails
[19:07:52] nzst: tycoon177: maybe something like this https://github.com/hiravgandhi/angularjs-rails/blob/master/lib/angularjs-rails/sprockets.rb
[19:08:54] tycoon177: nzst: thanks :) i was actually looking at the jquery-rails gem because the asset pipeline page on edgeguides.rubyonrails.com said that it was a good example
[19:09:08] za1b1tsu: has joined #RubyOnRails
[19:11:02] fox_mulder_cp: tuskkk___: i said some times: link_to - GET. button - POST
[19:11:19] fox_mulder_cp: so you need change your get link to to button actions
[19:13:57] conta: has joined #RubyOnRails
[19:16:28] mtkd: has joined #RubyOnRails
[19:17:52] mondz: has joined #RubyOnRails
[19:20:29] tdy: has joined #RubyOnRails
[19:22:57] tycoon177: nzst: thanks again! My middleware is including my javascript as intended now :)
[19:24:39] duderonomy: has joined #RubyOnRails
[19:26:13] tuskkk___: fox_mulder_cp: look at this please https://gist.github.com/prawadhwani/5ad291918dbdc75f9482c3162f6ace52
[19:26:23] tuskkk___: this is driving me nuts now
[19:26:29] nzst: tycoon177: cool, glad it worked out for you
[19:27:11] alfiemax: has joined #RubyOnRails
[19:28:50] fox_mulder_cp: tuskkk___: <% if ... %> some html <% else %> some html <% end %>. read render and view guides and be carefull. it's a bad way for propgrammer
[19:30:33] fox_mulder_cp: btw, folks. how i can decorate model name from MyEngine::User to User,as example, in main app?
[19:30:37] tuskkk___: ok, a fix for `link_to` please
[19:31:18] fox_mulder_cp: tuskkk___: read about view helpers like button, link_to and etc on edge guides
[19:31:18] tuskkk___: `No route matches {:action=>"destroy", :controller=>"rotation"}`
[19:31:41] fox_mulder_cp: tuskkk___: delete method. you blog app contains this link type :)
[19:32:25] fox_mulder_cp: tuskkk___: 300$ and i write your app for you :)_
[19:33:11] tuskkk___: good for you!
[19:38:41] nzst: tycoon177: did you come across any good resources for writing the custom rack middleware in your gem?
[19:42:08] fox_mulder_cp: Radar: hi. can you help with my engine model name references and decoration?
[19:46:10] tycoon177: nzst: no i didn't :( I had to read a few gems' source code to figure it out myself. Once I get a better grasp on it, i'm considering writing a blog post about it. it was pretty painful finding out how to write custom rack middleware, tbqh
[19:47:18] orbyt_: has joined #RubyOnRails
[19:48:01] tycoon177: nzst: that being said, I know rack middleware outside of a gem, in a folder like app/middleware is all of the benefit, none of the headache of bundling it with a gem. The hardest part about the gem was having it auto mount the middleware when the gem was included in the gemfile
[19:51:54] marr: has joined #RubyOnRails
[19:52:53] nzst: tycoon177: what was the trick for that? auto mounting when included in gem file?
[19:55:37] tycoon177: nzst: this is the only thing I was able to find that explained it enough https://stackoverflow.com/a/5730274
[19:56:59] tycoon177: nzst: and to top it off, I found this pattern in other middleware gems
[20:01:23] nzst: thanks for sharing, i've been trying to wrap my head around this middleware gem https://github.com/vigetlabs/redirector
[20:08:30] tycoon177: nzst: What are you having issues with in regards to that gem?
[20:10:41] nzst: tycoon177: just trying to grok it, nothing in particular. I've never really taken the time to understand rack and middleware and this gem was inline with a feature I got tasked with
[20:11:02] chouhoulis: has joined #RubyOnRails
[20:11:45] nzst: maybe this one isn't even rack related
[20:13:17] Puffball: has joined #RubyOnRails
[20:13:47] eckhardt_: has joined #RubyOnRails
[20:14:33] nzst: and i've been seeing rack pop up in feeds more with work going towards it for h2 support
[20:15:50] tycoon177: nzst: you probably don't want a rack middleware for your task
[20:16:41] nzst: tycoon177: why? i need a CRUD 302 redirect with a GUI. they're tired of requesting a dev to change up the routes.rb
[20:17:00] tycoon177: what is the task at hand?
[20:17:39] nzst: see above, just getting away from manually changing the routes.rb for 302 redirects and then having to deploy
[20:17:44] Puffball: has joined #RubyOnRails
[20:18:05] tycoon177: Why are you needing these routes to change?
[20:18:14] tycoon177: I think I'm missing some of the puzzle
[20:18:42] tycoon177: a middleware change will still require a deployment
[20:19:17] nzst: we build sites with a custom cms backing them. The client often has 302 redirects that need setup from links that got sent out in marketing material. Or they update a slug and it's helpful for them to not have dead links out in the wild
[20:19:31] hahuang65: has joined #RubyOnRails
[20:19:40] jottr: has joined #RubyOnRails
[20:19:40] nzst: so, we want to allow the client to create 302 redirects through the cms
[20:19:51] hahuang65: is #update! a no-op if the attributes are all the same as what already exists?
[20:21:22] tycoon177: nzst: you technically *could* use a middleware for this, but there's nothing stopping you from using a catchall route and a table in your db for redirect mapping
[20:21:44] tycoon177: nzst: i did something similar in another app at work. Let me find some code for you to reference
[20:24:59] tycoon177: nzst: https://gist.github.com/BenMcH/44c78c2270f88d5ce00cf134b42b77a6 Here's the general idea behind my idea. You *could* do this right in your rails routes once and then manage the redirects at the db level. If you truly don't want to handle this in rails, you *can* write a middleware and it'd respond slightly faster, but then you have to deal with supporting that middleware
[20:25:20] tycoon177: note: this code may not be great or even good
[20:26:28] nzst: thanks so much, another idea to try out if anything
[20:27:33] tycoon177: nzst: we use 2 of those in a single application to manage both a cms style of content filled pages and to handle category names or ids in the url. It works well for our uses, but we're pretty low traffic, so ymmv
[20:28:17] tycoon177: you might want to change `/:id` to `/:slug` in your case. Then you would be able to access it in the controller or view via `params[:slug]`
[20:29:15] jottr: has joined #RubyOnRails
[20:29:35] sidx64: has joined #RubyOnRails
[20:31:43] conceivably: When using ActionCable, what might be going on if it takes a long time to establish a connection? (As in 10+ seconds)
[20:33:02] uksio: has joined #RubyOnRails
[20:33:57] mroutis: has joined #RubyOnRails
[20:36:43] tycoon177: hahuang65: if everything is the same, i believe rails just does a begin and commit transaction
[20:37:23] sidx64_: has joined #RubyOnRails
[20:40:54] hahuang65: tycoon177: okay cool
[20:46:14] nzst: has left #RubyOnRails: ("Using Circe, the loveliest of all IRC clients")
[20:55:05] Technodrome: has joined #RubyOnRails
[21:04:07] gambl0re: has joined #RubyOnRails
[21:13:10] ur5us: has joined #RubyOnRails
[21:13:26] ur5us: has joined #RubyOnRails
[21:20:15] Technodrome: has joined #RubyOnRails
[21:21:31] mtkd: has joined #RubyOnRails
[21:34:52] nickenchuggets: has joined #RubyOnRails
[21:35:57] Ryanar: has joined #RubyOnRails
[21:38:16] GodFather: has joined #RubyOnRails
[21:38:34] orbyt_: has joined #RubyOnRails
[21:38:37] Ryanar: Hey all, if I have a User model with a Office model and want to return the User's Office.location_name field, is there anything I need to do so the Foreign Key lookup is optimized?
[21:39:10] tycoon177: Add an index to the database
[21:39:47] tycoon177: if i'm understanding correctly, you'll want an index on your users.office_id column
[21:42:38] hnanon: has joined #RubyOnRails
[21:43:25] hnanon: I have the following line:
[21:43:37] hnanon: <%= grouped_collection_select(:user, :location_id, @markets, :locations, :name, :id, :name, { prompt: "Select Primary Location", selected: @user.location_id }, { class: "form-control" })%>
[21:43:57] hnanon: So, the collection is markets, but I'm grouping by locations.
[21:44:55] hnanon: How can I only get locations with a particular attribute ie. where(status: "active")?
[21:57:19] Ryanar: tycoon177 thanks, didnt know if I needed to do any preloading like if accessing it would generate two SQL queries instead of a single query with JOIN
[22:00:18] roshanavand: has joined #RubyOnRails
[22:10:54] mroutis: has joined #RubyOnRails
[22:21:10] fox_mulder_cp: Ryanar user.office.location_name
[22:22:03] fox_mulder_cp: tycoon177 it indexed by default in migrations, if it properly created
[22:22:49] tycoon177: fox_mulder_cp: good to know! Thanks :) I usually forget that I can do an association like that in a migration
[22:23:01] Ryanar: my question was not how to access it, but whether or not it would generate two queries
[22:23:45] Ryanar: e.g. initial query would just select the foreign key, and when I call the show method which access a property on the foreign key, it would do another query for the actual model
[22:23:51] mikecmpbll: has joined #RubyOnRails
[22:24:44] Ryanar: so it would be initially User: { id: 3, name: 'Bob', office: 15 }, then it would do a second query for Office.id = 15, to get Office: { id: 15, location_name: '2nd Floor 2312' }
[22:25:16] fox_mulder_cp: Ryanar: hm. includes? joins?
[22:25:45] Ryanar: not sure what you are asking agent mulder
[22:25:50] fox_mulder_cp: Ryanar: office: 15 -> office_id: 15 -> user.office
[22:26:09] fox_mulder_cp: Ryanar: i pass some keywords for asccociations in rails
[22:27:36] fox_mulder_cp: btw, about associations. how i can decorate me engine model names for main app? like MyEngine::User has many MyEngine::Stories
[22:59:30] duderonomy: has joined #RubyOnRails
[22:59:46] chouhoulis: has joined #RubyOnRails
[23:01:19] duderonomy: has joined #RubyOnRails
[23:15:57] orbyt_: has joined #RubyOnRails
[23:20:03] eckhardt_: has joined #RubyOnRails
[23:58:34] Ericx2x: has joined #RubyOnRails