Skip to content

Commit

Permalink
Write example
Browse files Browse the repository at this point in the history
  • Loading branch information
tkawa committed Nov 29, 2012
1 parent dabdd02 commit cf992ff
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 8 deletions.
46 changes: 40 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,44 @@
# ResourcesIdReplace
# resources_id_replace

Replace param name of resources' id.
Useful for making user friendly URL.

## Example

You can use `:replace_id_with` option for `resources`.

```ruby
resources :users, :replace_id_with => 'name'
```

```
users GET /users(.:format) users#index
POST /users(.:format) users#create
new_user GET /users/new(.:format) users#new
edit_user GET /users/:name/edit(.:format) users#edit
user GET /users/:name(.:format) users#show
PUT /users/:name(.:format) users#update
DELETE /users/:name(.:format) users#destroy
```

Good with the following codes.

```ruby
class User < ActiveRecord::Base
def to_param
name
end
end
```

```ruby
class UsersController < ApplicationController
def show
@user = User.find_by_name!(params[:name])
end
end
```

TODO: Write a gem description

## Installation

Expand All @@ -16,10 +54,6 @@ Or install it yourself as:

$ gem install resources_id_replace

## Usage

TODO: Write usage instructions here

## Contributing

1. Fork it
Expand Down
4 changes: 2 additions & 2 deletions resources_id_replace.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ Gem::Specification.new do |gem|
gem.version = ResourcesIdReplace::VERSION
gem.authors = ["Toru KAWAMURA"]
gem.email = ["[email protected]"]
gem.description = %q{Replace path name of resources' id}
gem.summary = %q{Replace path name of resources' id}
gem.description = %q{Replace param name of resources' id}
gem.summary = %q{Replace param name of resources' id}
gem.homepage = "https://github.com/tkawa/resources_id_replace"

gem.files = `git ls-files`.split($/)
Expand Down

0 comments on commit cf992ff

Please sign in to comment.