Software Development |
Ruby on Rails
This plugin is used to create permalinks from attributes of models. The attribute is escaped to to make it safe to use in a URL in the after_validation callback. You can define a scope for a permalink which effectively makes includes a parent id into the permalink for the child model.
permalinks in altered_beast
Within altered_beast the migration 001_create_permalinks.rb adds permalinks to three already existing tables and attributes:
- Forum.name, for example, http://localhost:3000/forums/tea-making
- Topic.title within Forum, for example, http://localhost:3000/forums/tea-making/topics/ceremony
- User.login within Site
- I didn't get User.login permalink working.
Adding a permalink
To add a permalink to you need to update the:
- table schema
You need a migration to add a permalink field to the table:
In the model you need to specify has_permalink for the appropriate attribute. You also need to include a to_param method returning the permalink.
has_permalink :attribute_for_permalink def to_param permalink end