https://github.com/mcasimir/friendly_id_schema
A Ruby Micro Gem for use FriendlyId with ActiveRecordSchema
https://github.com/mcasimir/friendly_id_schema
Last synced: 2 months ago
JSON representation
A Ruby Micro Gem for use FriendlyId with ActiveRecordSchema
- Host: GitHub
- URL: https://github.com/mcasimir/friendly_id_schema
- Owner: mcasimir
- Created: 2012-05-24T00:28:15.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2012-05-24T00:30:58.000Z (about 13 years ago)
- Last Synced: 2025-01-28T03:17:37.167Z (4 months ago)
- Language: Ruby
- Size: 93.8 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FriendlyIdSchema
**FriendlyIdSchema** is a micro gem that combines [FriendlyId](https://github.com/norman/friendly_id) with [ActiveRecordSchema](https://github.com/mcasimir/active_record_schema)
## Installation
``` rb
gem 'friendly_id_schema', :git => "git://github.com/mcasimir/friendly_id_schema.git"
```## Usage
Call `#permalink` inside a model like this:
``` rb
class Post
permalinkfield :title
end
```and then run `rails g migration` with `--from` option to let ActiveRecordSchema generate the required migration
_ex._
rails g migration add_permalink_to_posts --from Post
### Specify a field to derive permalink
``` rb
class User
field :name
permalink :name
end
```### Use history
Run these commands first:
rails generate friendly_id
rake db:migrate``` rb
class Post
permalink :history => truefield :title
end
```