Archive of Ruby on Rails
Setting up simple OmniAuth authentication with Facebook
Posted on Feb 01 in Ruby on Rails, Tutorials | (11) CommentsIf you have watched Ryan Bates’ tutorial Simple OmniAuth you probably already know OmniAuth is awesome. Ryan doesn’t go into details about setting up OmniAuth with Facebook so this post has a couple of pointers to help out in that regard. It’s meant as a continuation to the screencast, so if you haven’t seen it [...]
If you have watched Ryan Bates’ tutorial Simple OmniAuth you probably already know OmniAuth is awesome.
Ryan doesn’t go into details about setting up OmniAuth with Facebook so this post has a couple of pointers to help out in that regard. It’s meant as a continuation to the screencast, so if you haven’t seen it start there.
Configuring Nginx and Unicorn
Posted on Jul 09 in General, Ruby on Rails, Scalability | (13) CommentsI first heard about Unicorn in an interview with 37Signal’s server admin Mark Imbriaco and it made me really curious. There are a few great resources explaining how Unicorn works and a neat benchmark comparing Mongrel, Passenger and Unicorn. I will share my experience playing with Nginx and Unicorn on a Debian Lenny box.
I first heard about Unicorn in an interview with 37Signal’s server admin Mark Imbriaco and it made me really curious. There are a few great resources explaining how Unicorn works and a neat benchmark comparing Mongrel, Passenger and Unicorn. I will share my experience playing with Nginx and Unicorn on a Debian Lenny box.
Handling paperclip attachments with the same name
Posted on Jun 16 in Ruby on Rails | (1) CommentThis quick post is about some Paperclip-related code that I see quite frequently that could cause problems. It’s easy to miss this stuff in development and then get major headaches later.
This quick post is about some Paperclip-related code that I see quite frequently that could cause problems. It’s easy to miss this stuff in development and then get major headaches later.
Adding multiple images to a Rails model with paperclip
Posted on Feb 13 in General, Ruby on Rails, Tutorials | (26) CommentsHow to add multiple images to a rails model – all in one form!
The Goal
I have been working on improving the admin section of a ski club website. The club sells ski trips online and they need to be able to create new trips from the admin panel. A trip has a title, description, date and price. For marketing reasons when the trip information is displayed on the website a number of pictures related to the trip are also displayed in a slideshow. The goal was to allow admins to add a new trip to the website (including the images) through a single form. Up until now, admins had to create the trip text data and then add the images separately through another form.
The Solution
The solution makes use of Paperclip (the awesome file attachment ruby gem) and the nested attribute functionality that has been added in rails 2.3. If you are new to these I strongly suggest watching these two screencasts from Railscasts: http://railscasts.com/episodes/196-nested-model-form-part-1 and http://railscasts.com/episodes/134-paperclip
To install paperclip add the following line to the environment.rb file and run rake:gems:install
config.gem "thoughtbot-paperclip", :lib => "paperclip" Read More
jQuery Validation in Ruby on Rails
Posted on Aug 17 in jQuery, Ruby on Rails, Tutorials | (40) CommentsThis post shows how you can use the jQuery Validation plugin to validate RESTful rails forms and how to use the remote method for powerful AJAX-backed validation.
In this post you will see how to do client side validation with jQuery in a Ruby on Rails application. The post assumes you have some knowledge of Ruby on Rails views and jQuery selectors.
We will validate a typical user registration form using the jQuery Validation plugin.