Page 1 of 1
[19:04:40] greenhat: drale2k: I generally prefer to save the user input unmodified and sanitize/linkify/etc at display time.
[19:06:16] greenhat: drale2k: That gives you a log more flexibility going forward. Perhaps one day you want to export the raw data, or change your linkifier, etc.
[02:36:35] greenhat: Take a look at the spec DSL included with minitest. It is my personal preference.
[02:37:56] greenhat: If nothing else the comments are worth reading for lulz https://github.com/seattlerb/minitest/blob/master/lib/minitest/spec.rb
[20:15:07] greenhat: siaw: after_create will run after the object is saved to the database, so the capitalization is not persisted.
[17:47:21] greenhat: renegadeandy: If you require 'open-uri' then you can open a URL just like a file. So I bet you could do self.photo = open(url).
[18:04:23] greenhat: Just reading your SO question. I don't think you want to use paperclip in the case of the default image. It would download and store multiple copies of the default image.
[18:09:25] greenhat: Yeah. Just what I was typing - I would just store the photo url in a separate `canned_url` attribute, and have a method like `def photo_url; canned_url || photo.url; end`
[18:10:22] greenhat: That hides the implementation behind a method - rather than exposing the implementation via event.photo.url.
[18:27:08] greenhat: flip_digits: I've never heard of a book specifically on consuming apis. General programming and architecture books help.
[18:28:00] greenhat: flip_digits: Typically in a rails app you want to call 3rd party services in a background job - so you would use one of these https://www.ruby-toolbox.com/categories/Background_Jobs
[18:28:36] greenhat: You would handle the entire request/response in the background job including error handling.
[18:41:32] greenhat: flip_digits: Maybe you email the user about the error (credit card declined). Maybe you just retry every 10 minutes, etc.
[16:47:35] greenhat: I'm guessing you want something like params.require(:email).permit(:to, :from, :template, :content)
[16:49:57] greenhat: Given that you aren't using mass assignment in that code I don't think strong params buys you much anyway.
[21:03:18] greenhat: TIL the hard way if you call two different controller actions in a controller test any ivars set in the first action are still set in the second action.
[20:37:28] greenhat: ror15: Did you mix in the factory_girl methods? https://github.com/thoughtbot/factory_girl/blob/master/GETTING_STARTED.md#configure-your-test-suite
[20:43:08] greenhat: ror15: Also, hardcoding counts (where you expect Contact.count) to equal 1 will eventually bite you. You just just check that Contact.count has gone up by one.
[20:43:34] greenhat: With minitest you would use assert_difference. I don't know the rspec equivalent.
[23:27:21] greenhat: a1fa: No doubt. But I've talked to some of them and for the most part they give me a thumbs up.
[17:27:53] greenhat: I'm using standard transactional minitest tests on this rails project. Is there any callback or method I can override to write some stuff to the DB before the transaction is opened when a test runs?
[17:29:24] greenhat: I know that's basically what fixtures are, but this project is using factories, and I don't really want to use a fixture just for this case.
[17:32:17] greenhat: Yeah. I know. The tests would run 16x faster if I only need to setup the data once.
[17:36:11] greenhat: reckoner, You should be able to just include Pundit in any object you want, and you get the helper methods.
[17:36:58] greenhat: reckoner, Or you can just new up the policy you want - PostPolicy.new(user, post).destroy? - for example.
[17:44:27] greenhat: The pundit helper methods (#authorize, #policy) expect there to be a #current_user method available to know what user to authorize the action against.
[17:49:19] greenhat: reckoner, you can implement a `pundit_user` method that does the right thing. By default `pundit_user` just delegates to `current_user`
[17:50:44] greenhat: reckoner, No problem. I suggest reading the pundit code too. It is really lightweight and pretty easy to understand.
[07:06:08] greenhat: It depends entirely on your app, but one way to keep it simple is a bg job and a flash message like "1000 users queued for removal."
[07:08:00] greenhat: Ha. There's nothing that prevents your user from nav'ing back to the index page anyway. I wouldn't be able to sleep knowing a I wrote a synchronous request that takes 10+ seconds :)
[16:16:14] greenhat: Yes, lazy attributes might work. I usually figure out factory girl through trial and error - try something, set a break point in the test and examine the data and see if it did what I want.
[16:39:55] greenhat: I have used pundit on an old system that already had some cancan. Pundit is super simple and doesn't interfere.
[17:07:46] greenhat: I use polymorphic belongs_to and have one table for images. Works pretty well. It does get a bit sketchy if you start having divergent business logic for different types of images.
[17:09:01] greenhat: Now we have several subclasses of Image using STI, so we have a polymorphic belongs_to to an STI images table and some crazy image factory stuff. I'm not proud.
[21:55:58] greenhat: It looks like adding methods in a rake file just adds those methods to Object, even if you declare the methods in a rake namespace.
[21:58:47] greenhat: Is there a suggested way to create functions in a rake file where they don't get added to the global namespace?
[00:29:12] greenhat: Ryn each test in the scope of a transaction and the before(all) data should be clean for each test, right?
[04:59:00] greenhat: I used to manually compile rubies and manually update symlinks. Then I discovered RVM and it was great. Then bundler made most of RVM unnecessary for me and I switched to chruby and ruby-build and it is great.
[04:59:32] greenhat: I hope one day native OS packages will get their act together and I won't need any ruby version managers at all, and it will be great.
[18:59:45] greenhat: Consider Heroku if that's a possibility and you don't want to learn to be a sys admin overnight :)
[15:28:07] greenhat: direnv is great. ./bin is only in your path when you are in your project directory.
[15:48:01] greenhat: Victory. I think I managed to configure an entire rails app using env vars. Not that easy.
[15:49:08] greenhat: There appears to be no single place where you can define all the env vars. As far as I can tell. Using ubuntu servers.
[15:50:02] greenhat: Because I'm playing with docker, and the easiest way to configure docker containers is with env vars.
[15:50:46] greenhat: Currently the app is running on ubuntu servers. Would like to give docker a go.
[15:52:07] greenhat: If you have a platform that can run ruby and you can set env vars it can probably run the rails app.
[19:40:06] greenhat: was seeing the same issue with rgeo-geojson - cannot install the latest but it is listed on the website
[17:14:49] greenhat: jdeen: If so I suggest putting them in app/presenters, not app/views/presenters.
[17:15:50] greenhat: jdeen: Then you put your tests in spec/presenters and inherit from whatever the standard unit tests inherit from (I assume. I use minitest)
[01:44:13] greenhat: benlieb: Generally things that can be done in application code should be done there. Most validation for example. Some things can only be done properly on the DB though - like uniqueness checks.
[01:45:08] greenhat: So, it boils down to using the right tool for the job and most often that is the application code.
[01:54:09] greenhat: I haven't had to use them much. If you are writing an app on top of a legacy db I think they can be useful.
[01:54:54] greenhat: I've been tempted to use a view in place of a few heinous joins we've got though. Haven't tried it out yet.
[01:56:14] greenhat: There could be a significant performance advantage using a view depending on the DB being used. But so far performance of the joins isn't a problem.
[02:01:10] greenhat: benlieb: It should just treat it as any other table. Just create a model with a matching name.
[23:23:16] greenhat: Just upgraded to rails 4.1. Every time I run rake assets:precompile new files with different fingerprints are generated, but I haven't changed any files.
[00:52:57] greenhat: If you are copying a file so big you need a progress bar there's probably significant overhead in encrypting and decrypting the file through scp.
[00:56:33] greenhat: reppard: Ah. In that case USB is slow enough that the encryption time would be negligible.
[01:10:30] greenhat: If scp can keep the usb2 pipe full there wouldn't be much overhead. On fast disks there would be more.
[01:19:37] greenhat: My buddy just pointed me to pv http://www.cyberciti.biz/open-source/command-line-hacks/pv-command-examples/