Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 34 lines (19 sloc) 1.197 kb
791265d @eifion Fixed README file.
authored
1 # URL Formatter [![Build Status](https://secure.travis-ci.org/eifion/url_formatter.png)](https://secure.travis-ci.org/eifion/url_formatter.png)
f4b140b @eifion Added README file.
authored
2
3 Format and validate a URL attribute in Active Record. This is an example gem created for [RailsCasts episode #301](http://railscasts.com/episodes/301-extracting-a-ruby-gem).
4
5 ## Installation
6
7 Add to your Gemfile and run the `bundle` command to install it.
8
9 ```ruby
10 gem "url_formatter"
11 ```
12
13 **Requires Ruby 1.9.2 or later.**
14
15
16 ## Usage
17
18 Call `format_url` in an ActiveRecord class and pass the name of the attribute you wish to format into a URL and validate.
19
20 ```ruby
21 class Comment < ActiveRecord::Base
22 format_url :website
23 end
24 ```
25
26 This will automatically add "http://" to the beginning of the `website` attribute upon saving if no protocol is present. It will also do validation to ensure it looks like a URL.
27
28
29 ## Development
30
31 Questions or problems? Please post them on the [issue tracker](https://github.com/ryanb/url_formatter/issues). You can contribute changes by forking the project and submitting a pull request. You can ensure the tests passing by running `bundle` and `rake`.
32
33 This gem is created by Ryan Bates and is under the MIT License.
Something went wrong with that request. Please try again.