rails_navigation
Simplify matching of Rails routes. Did you ever hate the link_to_if helper? E.g.:
<%= link_to_if(@current_user.nil?, "Login", { controller: "sessions", action: "new" }) %>
Then try this gem! You can now match controllers and actions like defined in the routes.rb.
Examples
Matching controllers:
{ controller: "pages", action: "new" } becomes 'pages'
Matching controllers and actions:
{ controller: "pages", action: "new" } becomes 'pages#new'
Matching controllers, actions and params:
{ controller: "pages", action: "show", params: { id: 'homepage' } } becomes 'pages#new?id=homepage'
Or even simpler (id is the default):
{ controller: "pages", action: "show", params: { id: 'homepage' } } becomes 'pages#new?homepage'
Installation
Add this line to your application's Gemfile:
gem 'rails_navigation'
And then execute:
$ bundle
Usage
TODO: Write usage instructions here
TODO
- Match multiple conditions
Contributing
- Fork it ( https://github.com/sbrink/rails_navigation/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request