Sha256: c8df586d57ad33b266f7deb33c3e6924ea38151ab3db6dcf637fd6c686b0a0db

Contents?: true

Size: 1.73 KB

Versions: 1

Compression:

Stored size: 1.73 KB

Contents

# RailsTemplatedUrls

This gem provides some helpers to build [templated URLS][1] based on the named
routes of your Rails application.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'rails_templated_urls'
```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install rails_templated_urls

## Usage

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.

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/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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_templated_urls-0.1.3 README.md