README.md in rails_templated_urls-0.1.2 vs README.md in rails_templated_urls-0.1.3

- old
+ new

@@ -1,11 +1,10 @@ # RailsTemplatedUrls -Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rails_templated_urls`. To experiment with that code, run `bin/console` for an interactive prompt. +This gem provides some helpers to build [templated URLS][1] based on the named +routes of your Rails application. -TODO: Delete this and the text above, and describe your gem - ## Installation Add this line to your application's Gemfile: ```ruby @@ -20,20 +19,48 @@ $ gem install rails_templated_urls ## Usage -TODO: Write usage instructions here +Assuming you have the following route on your `routes.rb` file: +```ruby +Rails.application.routes.draw do + resources :books +end +``` + +You can use the following helpers on your views: + +```ruby +templated_path :books # => "/books" +templated_path :book # => "/books/{id}" +templated_path :edit_book # => "/books/{id}/edit" +templated_path :books, :foo, :bar # => "/books{?foo,bar}" +``` + +If you want the full URL, you can use another helper: + +```ruby +templated_url :book # => "http://localhost:3000/books/{id}" +``` + ## Development -After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment. +After checking out the repo, run `bin/setup` to install dependencies. Then, run +`bin/console` for an interactive prompt that will allow you to experiment. -To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). +To install this gem onto your local machine, run `bundle exec rake install`. To +release a new version, update the version number in `version.rb`, and then run +`bundle exec rake release` to create a git tag for the version, push git commits +and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). ## Contributing -1. Fork it ( https://github.com/[my-github-username]/rails_templated_urls/fork ) +1. Fork it ( https://github.com/lenon/rails_templated_urls/fork ) 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create a new Pull Request + +[1]: http://tools.ietf.org/html/rfc6570 +[2]: http://devdocs.io/rails/abstractcontroller/helpers/classmethods#method-i-helper