What I find interesting.....
How to Remove the “X” on jQuery UI dialog
How to Remove the “X” on jQuery UI dialog

I’ve just recently started learning how to use the jQuery UI framework.  Seems very useful, and although I haven’t personally tested yet, supposedly has good cross browser support.

I use the jQuery UI dialog boxon my site. I’ll write another post about how to customize them completely, but in this case I just wanted to remove the close “X” in the upper right corner that comes in the dialog box by…

View On WordPress

How to Create An Alert Confirm Dialog in CoffeeScript

New post on my Ruby on Rails blog!

View On WordPress

Alert Confirm Dialog in CoffeeScript

Alert Confirm Dialog in CoffeeScript

I was trying to figure out how to create a confirmation alert dialog in coffeescript. Turns out like almost everything in coffeescript, its super easy.

$(".mybutton").on "click", ->
  if confirm "Ask a question?"
    # if answer yes
    # if answer no

credit here

View On WordPress

How to Center Bootstrap Columns

Sometimes you want to center the columns when using Bootstrap.  I was using only like 3 columns of varying sizes, but I wanted to get them centered. So here’s how I did it, with all credit going to minimit and this article.

Add the .row-centered class to your rows and the .col-centered class to the columns in your html.

And here’s the css for those classes:

/* centered columns styles */…

View On WordPress

Create a PDF with Prawn

Prawn is a pdf generator built in ruby, that is pretty full featured.  However, I found it pretty hard to find good current documentation on using it in Rails.  Much of it was years old, and referred to older versions of prawn and older versions of Rails.  Ryan Bates’ RailsCast #153 was very helpful though, as usual.

Fortunately, there is a gem we can use:

gem 'prawn'

And of course run bundle…

View On WordPress

CSS or Javascript Assets not Working on Heroku Production

I had a weird issue where on my local environment, everything worked fine, but on production when pushed to heroku, my javascript and css files weren’t getting loaded.

Now I don’t fully understand the asset pipeline and if/how it was involved in this error, but here’s what worked for me.

Simply manually precompile assets prior to pushing to heroku:

bundle exec rake assets:precompile

You will…

View On WordPress

Save PDF to User Model in Ruby on Rails Using Paperclip and Prawn

I’m using paperclip and prawn to create pdf certificates for users and save them to the user model in the background.

Paperclip is often used for user uploaded files, such as images, so I was uncertain how to save the pdf that was created with prawn to the user model, since the user did not upload it themselves.  Actually turns out its pretty simple.

One the pdf is created with Prawn (which I’ll…

View On WordPress

Formatting Date in Ruby on Rails

So by default when I used Date.today, the date came out like this 2014/09/05.  However many times you want to display it various formats. This won’t be a comprehensive post on date formatting, but here a few resources that helped me accomplish what I was looking for.

I wanted the date to be formatted like this: Friday, September 5, 2014.  To do this,

Date.today.strftime("%A %B %e %Y ")

A very…

View On WordPress

What Fonts are available in Prawn PDF for Rails?

I use prawn (both the prawn gem and prawn_rails gem by Whoops- note it’s an underscore, not a dash) to create pdf’s in my rails app.  You can customize the font to some extent, but here is a list of the available fonts by default that you can use in your prawn pdf:

Courier Helvetica Times-Roman Symbol ZapfDingbats
Courier-Bold Courier-Oblique Courier-BoldOblique
Times-Bold Times-Italic…

View On WordPress