Sha256: f3f06e1634fb94743c812e3a17ffa25951ec0fefa9d981b8551f041e2e05c253

Contents?: true

Size: 1.69 KB

Versions: 2

Compression:

Stored size: 1.69 KB

Contents

# SimpleBreadcrumbs

This gem provides a simple and flexible way to create breadcrumbs with Rails active record 
models. Setting `has_breadcrumb` on a model will enable a view method,
`breadcrumb()`, which will show the links to the page and its parents in
a breadcrumb format.

## Installation

Add this line to your application's Gemfile:

    gem 'simple_breadcrumbs'

And then execute:

    $ bundle

## Usage

In your model:

    class User < ActiveRecord::Base
      has_breadcrumb :title => :username
    end

To display a model as a child of another model, you state the parent
by using the `:parent` parameter:

    class UserProfile < ActiveRecord::Base
      has_breadcrumb :parent => :user, :title => "Profile"
    end

As can be seen here, `has_breadcrumb` can accept a `String` on the
`:title` option, which is useful in the case where there is no field in
the model which would be suitable. The `:parent` option however, must
take a `Symbol`.

Breadcrumb links are displayed in a view by including the `breadcrumb` erb tag. 
For example in an erb view for creating a new user,

    <h2 class="subtitle"><%= breadcrumb @user, 'New' %></h2>

will provide a link which includes the Index page and the controller
action to which this page is related.

Other options allowed by the `breadcrumb` method include
`:forced_parent`, which links to a non-natural parent of the current
view page.

By default, `breadcrumb` includes a link to the index of an object when only
one level exists.

## Contributing

1. Fork it
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 new Pull Request

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
simple_breadcrumbs-0.0.2 README.md
simple_breadcrumbs-0.0.1 README.md