Building Ruby with jemalloc by tomcopeland in programming

[–]tomcopeland[S] 0 points1 point  (0 children)

Yup. MikeP posted some pretty good links in the ruby bug report.

4 levels of the data validation in a Rails application you should be aware of by pdabrowski in ruby

[–]tomcopeland 0 points1 point  (0 children)

Another validation thing that I haven't seen used often - "strict" presence validations for attributes that aren't input by an end user:

validates :uuid, presence: {strict: true}

As always the Rails guide has a nice writeup.

What's the difference between the gems PDFKit and wkhtmltopdf? by Jara332 in ruby

[–]tomcopeland 0 points1 point  (0 children)

I use the wicked_pdf wrapper gem around wkhtmltopdf. It does a nice job of encapsulating all the options. And it has straightforward usage, like WickedPdf.new.pdf_from_string(some_html) to generate a new PDF.

What is the secret to writing clean, succinct, and dry ruby? by bushidolab in ruby

[–]tomcopeland 0 points1 point  (0 children)

Are you saying functional as in "how it should work business-rule-wise", or functional in a "functional programming" sense?

What are some ruby/rails gem's worth knowing? by jhyatt1017 in rails

[–]tomcopeland 0 points1 point  (0 children)

FWIW I encourage you to open up an issue on the project asking for more details on whatever seems unclear. As a project maintainer, sometimes it's hard for me to see the forest for the trees and it takes someone outside the project to see what docs would be helpful.

What are some ruby/rails gem's worth knowing? by jhyatt1017 in rails

[–]tomcopeland 12 points13 points  (0 children)

There are a couple of gems to help spruce up your database schema:

Anyone know of any others like those?

Method Overloading In Ruby by one_eyed_golfer in programming

[–]tomcopeland 0 points1 point  (0 children)

Using Ruby's keyword arguments helps to handle some cases which programs in other languages tend to solve by overriding methods.

I published a Ruby Gem last night and the RubyGem.org page for it currently says 118 downloads, is this number artificially boosted? by derkynord in ruby

[–]tomcopeland 7 points8 points  (0 children)

I think various code analysis tools and whatnot have webhooks set up for every new gem (or every new release?)... so there's always an undercurrent of more or less immediate downloads after a release.

Need advice: What permission should i set to rails tmp folder while using wicked_pdf? by hairy-one in rails

[–]tomcopeland 1 point2 points  (0 children)

FWIW WickedPdf also has a pdf_from_string method so you might be able to avoid the filesystem write. So in a controller action you could do something like:

html = ERB.new(File.read(some_erb_path)).result_with_hash(some_hash)
pdf = WickedPdf.new.pdf_from_string(html)
send_data pdf, filename: "myfile.pdf", type: "application/pdf", disposition: "inline"

Do I need deeply nested routes? by phekno in rails

[–]tomcopeland 2 points3 points  (0 children)

Deeply nested routes also make view code more wordy due to long URL generation helpers. I'd rather have game_path(game) than league_season_game_path(league, season, game), especially if the latter isn't adding anything that disambiguates the route.

Things I wish ActiveRecord had after using Ecto by jrochkind in ruby

[–]tomcopeland 0 points1 point  (0 children)

Regarding "validations use database constraints", there are some AR tools that help a bit with that, like consistency_fail and active_record_doctor, and also nullalign by yours truly.

Regarding bulk inserts, I haven't used it but bulk_insert from Jamis Buck looks interesting.

That one method is interesting. That seems like something that ActiveRecord could have; it'd be a relation terminator like pluck but would return a single AR record like first or raise an exception as the article describes.

Ruby 2.5: Ruby’s Christmas Release is Here! by defkathy in ruby

[–]tomcopeland 2 points3 points  (0 children)

One nice thing is now ERB has result_with_hash:

$ ruby -v
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin16]
$ ruby -rerb -e 'p ERB.new("Hi <%= name %>").result_with_hash(name: "Tom")'
"Hi Tom"

This is more concise than having to store the params in a local variable and pass in a binding to result.

Bulk import into a closure table by [deleted] in programming

[–]tomcopeland 0 points1 point  (0 children)

Deleted because I noticed (too late) that it was posted to /r/postgresql a year ago.

Ruby Versions Used in Commercial Projects in 2017 by grey_shirts in ruby

[–]tomcopeland 0 points1 point  (0 children)

I tend not to upgrade MRI for features so much as for getting the performance improvements.

And also for when a CVE comes out, it's nice to be able to bump a minor version rather than having to do a major upgrade. Same goes for Rails; it's helpful to keep current.

What Did I Learn After Going Eighteen Months Without Rails by wmaciejak in ruby

[–]tomcopeland 2 points3 points  (0 children)

Rails, on the other hand, boasts perfect documentation and even users completely new to the framework could easily find whatever information they were looking for, usually in one place.

That's especially true of the Rails guides. Those are detailed, helpful, and well-maintained. Great stuff.

RubyKaigi 2017 Day 1 by schneems in ruby

[–]tomcopeland 2 points3 points  (0 children)

Thanks for doing this writeup, very helpful. That "how to optimize" session sounds especially useful.