#RubyOnRails - 30 May 2018
« Back 1 day Forward 1 day »
[00:01:36] jstrong: I have DatabaseCleaner installed with truncation strategy yet when I run my test suite and the first example is hit all my tables are deleted from the test database
[00:02:01] jstrong: This is my spec_helper.rb file: https://gist.github.com/laspluviosillas/910afd3f2bd575cce42bfc8dbaf0f353
[00:20:28] jstrong: Not totally out of the woods yet but I’m using a shared database across a couple of Rails’ apps and one is configured (correctly) to use structure.sql instead of schema.rb
[00:22:48] jstrong: Radar: What’s interesting is that running rspec in development mode doesn’t have that behaviour
[00:31:49] Radar: development mode isn't configured to attempt to load from db/schema.rb on every bootup
[00:32:04] Radar: https://gist.github.com/laspluviosillas/910afd3f2bd575cce42bfc8dbaf0f353#file-spec_helper-rb-L31
[00:32:28] Radar: Your gist calls it spec_helper.rb but I'm pretty sure it's rails_helper.rb that you've included htere
[02:07:41] MrCrackPotBuilde: could i use a on document load function then have a on document ready function inside that function ??
[04:34:04] madbear: good morning, i did just set up our rails env on my old, just call it laptop... 4GB of ram, running the environment 'rails s', no problem
[06:07:05] mices: I generated a mailer named GeneralMailer but when I try to call it from the admin_controller.rb i get an error not recognized undefined method `GeneralMailer' for #<AdminController:0x007f0c70a660c0>
[06:08:49] mices: i'm using a form for subject and message to send mail to all users so i put in the subject message and click submit
[06:09:22] mices: i was trying to do it with a get request but rails kept asking for post so i said let me see what'll happen if i change it to post
[07:08:28] yottanami: Here is my Concern methods https://github.com/yottanami/indie-otp/blob/master/lib/user_helper.rb and I am trying to call the method in my main app so I used it like this http://dpaste.com/0MZGRPC but the current_user is undefined.
[07:09:43] sevenseacat: I'm surprised the include works, because your UserHelper doesnt have that namespace
[07:14:01] yottanami: sevenseacat, I also tried change it to this http://dpaste.com/1M4RS4R but does not work yet and There is no error during include
[07:17:30] tbuehlmann: it works because that's how ruby resolves constants. as long as there's the namespace existing, the constant is found. this will work as well: Indie::Otp::AnyModelFromAppModels
[07:28:10] tbuehlmann: https://gist.github.com/tbuehlmann/c03f13a31a715a13b886dd49ef281f8a fun times
[07:50:48] yottanami: tbuehlmann, Thanks for your help, I moved the module to sub directories it seems there is no problem during include but current_user is undefined yet
[08:05:42] yottanami: tbuehlmann, Here is the module https://github.com/yottanami/indie-otp/blob/master/lib/indie/otp.rb and here is the controller https://gist.github.com/yottanami/85de2d8bdc7b084b6ac991e83eb368b4
[08:07:20] tbuehlmann: you are including Indie::Otp::UserHelper in your controller. where does that come from?
[08:17:54] yottanami: tbuehlmann, It is in my engine, and I need to use it in main application controllers
[08:18:01] yottanami: tbuehlmann, you can see the whole project here: https://github.com/yottanami/indie-otp/
[08:20:37] tbuehlmann: right now the methods resides in Indie::Otp, so you'd need to include that module
[08:27:24] yottanami: tbuehlmann, You mean I need something like this in my controller? `include Indie::Otp`
[09:35:13] GeorgesLeYeti: I have a set of 3 integer variables (a, b and c). One and only one variable must be define. For example a = 3 => b = c = nil OR b = 5 => a = c = nil. And i would like to check if these conditions are ok
[09:36:14] GeorgesLeYeti: I thought about (!a.nil? && b.nil? && c.nil?) || (a.nil? && !b.nil? && c.nil?) || (a.nil? && b.nil? && !c.nil)
[12:01:11] jane_booty_doe: Does it just give me access to local variables in the scenario (doing feature specs)
[13:35:24] xhoy: Anybody any experience with access key's on mobile browsers? (how do i do alt+shift+<accesskey> in amobile browser without a keyboard?)
[13:57:21] charlielor: I have Date::DATE_FORMATS[:release_date] = "%B %Y" in my date_formats.erb initializers folder and in my index file, I have <%= movie.released_on.to_s(:release_date) %> but it’s not working.
[14:12:42] tbuehlmann: charlielor: I don't know, but you could install the i18n-debug gem and check what translations is looked up by calling that
[14:13:43] charlielor: tbuehlmann: Thanks! I have checked the ruby on rails api documentation and a couple youtube video and it seems like what I have should work but it’s not so I’m a bit confused.
[14:22:35] charlielor: tbuehlmann: I did tried Time::DATE_FORMATS[:release_date] = "%B %Y" and it still shows 2018-04-12 instead. The issue seems to be <%= movie.released_on.to_s(:release_date) %>
[14:23:24] charlielor: As soon as I changed to :release_date it defaults to 2018-04-12. If I change it it to :long then it’ll show April 12, 2018
[14:24:18] charlielor: For it does look like the connection from :release_date to the custom date is not there, but it’s not there, there should be an error somehow, I assumed.
[14:29:52] tbuehlmann: get to go, but you could check the source code of that to_s method. in my case (rails 5.2), setting Time::DATE_FORMATS[:release_date] worked
[14:35:17] RougeR: why does rails not throw a warning when you try to create a model/controller with non conventional pluralisation
[14:35:51] Psy-Q: i'm trying to throw together a REST APi with jsonapi-rb and rails in API mode. it seems i have to construct the URLs (e.g. for "self") myself, there are no URL helpers or the like for use inside the serializer?
[14:57:29] grizwako: I am new to Ruby and Rails, trying to execute a function when model is being saved.
[15:00:12] grizwako: How do I tell Rails to just copy one attribute AS-IS and not wrap it into quotes?
[15:04:47] grizwako: basically, I am trying to modify a model, when it is being saved, it should encrypt one attribute via pgcrypto module.
[15:11:53] tuelz: is there a idiomatic way to wrap an activerecord field in a serialization/deserialization method? I've got a uuid field that is being serialized into hex values that I'd like for the rest of my application when referencing it to get the deserialized version of it
[15:13:01] tuelz: so right now if I just put a method for the field on the model - I can get it to deserialize cleanly for instances of that model
[15:13:34] RougeR: i just spent 2 hours without realising i didnt pluralise a controller months back
[15:13:50] RougeR: so i went in to the rails controller generator config files and added a validation
[17:33:03] manjaroi3_: Hi. Complete ruby noob here (never written a line of code) but been tasked with maintaining someone elses application, and I have been told I need to run rake db:migrate, but when I do I get "connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432", but thats not what my $DB_HOST variable says, I dont understand why its trying to connect to that db
[17:48:41] havenwood: manjaroi3_: You're seeing "/var/run/postgresql/.s.PGSQL.5432" but from the DB_HOST env var what are you expecting?
[18:27:21] cagomez: I have a JSONB column which is an array of users (each is a JSON object). is there a way to set a default value for a k, v pair for my user JSON objects? ie set a default "email" key with an empty string
[19:40:01] fryguy: hrmm, trying to fix an issue in one of my environments where `bin/rails c` complains that rake isn't installed, but `bundle show rake` shows it as being installed, and `bundle install` doesn't do anything and lists it as already installed. Not sure where else to look for mixup
[21:12:43] lupine: that'd be it. probably fine, but worth checking what it does when a request gets a 500 response
[21:13:14] lupine: (lighthttpd is bad by default, nginx is good by default, but both can be configured to the opposite behaviour)
[21:20:07] Inside: So someone visits root, clicks on "Unit Serial Numbers", which forces the first request through turbolinks, but <head> is different so the page gets fully reloaded, then the form gets filled out and the first POST... then a second post five seconds later.
[21:22:42] Inside: I actually have turbolinks disabled in the UnitSerialNumbers controller which is why I it (I presume) forces the second reload
[21:25:38] Inside: well - when you click on a link, turbolinks does a GET, right? Then it compares the contents -- but I have a no_turbolinks layout which has data-no-turbolink everywhery -- so I presume that it just reloads the page from scratch
[21:27:48] lupine: I'm not confident that it's the source of your problem but I'd certainly try hard to rule it out
[21:31:13] Inside: I've talked to the operator and he says that occasionally the browser will 'Freeze up' and then it generates two serial numbers in a row (as evidenced by two labels popping out of the printer through a rube goldberg websockets->ffi->winprint contraption)
[21:33:15] lupine: as a workaround, you could embed a uniq id into the form and reject requests that look like duplicates. stripe and mastodon both do this
[21:33:41] Inside: https://stackoverflow.com/questions/48179256/chrome-reinitiates-ajax-post-request-after-a-10-second-timeout
[21:34:43] lupine: presumably you can rule it in (or out) by trying to exercise that specific behaviour
[21:38:32] havenwood: lupine: Eww, Stripe! Fixed ;-P https://docs.connect.squareup.com/basics/api101/idempotency