# Railscrumbs
*Railscrumbs* a simple Breadcrumbs navigation plugin for rails.
## Requirements
* rails >= 3.1
## Installation
Add this line to your application's Gemfile:
gem 'rails_crumbs'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install rails_crumbs
## Usage
In your controller, call `set_railscrumb` to push s new element to Railscrumbs stack.
class MyController < ApplicationController
def index
set_railscrumb 'My Controller', mycontroler_path
...
end
end
Or if you can only some methods
class MyController < ApplicationController
set_railscrumb 'Home', :root_path
set_railscrumb 'My Controller', :some_path, :only => [:index, :new]
def index
...
end
def show
@anything = ....
set_railscrumb @some.name, anything_path(@anything)
...
end
def new
...
end
end
to render the Railscrumb you can call on the `application.html.erb` file to Railscrumbs stack.
My Title
<% @railscrumbs.each do |crumb| %>
<%= crumb.name %>
<%= ' >> ' unless crumb == @railscrumbs.last %>
<% end %>
<%= yield %>
### Arguments
*set_railscrumb* requires two arguments:
*`name`: Name of the breadcrumb
*`path`: Target path, if your railscrumb are out of a method, you have to use a symbol (e.g :root_path ). in a method like 'show', you can use the helper method (e.g user_path(@user) or users_path )
#### optional arguments:
`only` the specification of the controller methods for the breadcrumb
#### custom arguments:
if you wanna have custom value for your breadcrumbs, you can pass the argument like `:custom => 'some value`
and use like `<%= @railscrumbs.first.custom %> `, this show 'some value'
for example if you wanna specify a icon value for the css you can pass like this
class MyController < ApplicationController
def index
set_railscrumb 'My Controller', mycontroler_path, :icon => 'mycontroller'
...
end
end
and in `application.html.erb`:
<% @railscrumbs.each do |crumb| %>
<%= crumb.name %>
<%= ' >> ' unless crumb == @railscrumbs.last %>
<% end %>
## 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