Thursday, December 16, 2010

tabs and navigation menus rails

Tabs on Rails

TabsOnRails is a simple Rails plugin for creating tabs and navigation menus.
It provides helpers for generating navigation menus with a flexible interface.
Requirements

* Ruby >= 1.8.6
* Rails >= 2.2

or

* Rails 3

Warning: TabsOnRails doesn’t work with Rails 2.1 or previous versions (see this comment and this commit).
Installation
As a Gem

RubyGems is the preferred way to install TabsOnRails and the best way if you want install a stable version.

$ gem install tabs_on_rails

You might need administrator privileges on your system to install the Gem.
Rails >= 2.2

Specify the Gem dependency in your environment.rb file so that Rails will automatically check the requirement on startup.

Rails::Initializer.run do |config|

# other configurations
# ...

config.gem "tabs_on_rails"

end

Rails 3

Specify the Gem dependency in the Bundler Gemfile.

gem "tabs_on_rails"

As a Plugin

$ script/plugin install git://github.com/weppos/tabs_on_rails.git

Warning: this method is deprecated and will be removed in a future version.
Use Bundler and the :git option if you want to grab the latest version from the Git repository.
Basic Usage

In your template use the tabs_tag helper to create your tab.







The example above produces the following HTML output.


The usage is similar to the Rails route file. You create named tabs with the syntax tab.name_of_tab. The name you use creating a tab is the same you’re going to refer to in your controller when you want to mark a tab as the current tab.

class DashboardController < ApplicationController set_tab :dashboard end Now, if the action belongs to DashboardController, the template will automatically render the following HTML code.

Use the current_tab helper method if you need to access the value of current tab in your controller or template.

class DashboardController < ApplicationController set_tab :dashboard end # In your view
The name of current tab is .


http://www.simonecarletti.com/code/tabs_on_rails/

No comments:

Post a Comment