The easiest way to add tabbed navigation to your Rails app!
Posted by Paolo Mon, 24 Jul 2006 01:09:00 GMT
UPDATE Feb 01, 2007: the Tabnav has been updated in order to work wit Rails 1.2, read this post fom more info.
Hi guys, during our development efforts we needed tabbed navigations. Well, after struggling with the acts_as_wizard plugin (you can find it in the toolbox) we decided to implement yet another rails plugin, and we think this time it’s even easier to use and someway plain cool.
Tabnav it’s so far the easiest way to build tabbed navigation like this:
All this magic it’s done by this fragment of code put inside my layout:
<%= start_tabnav :main %>
<%= @content_for_layout %>
<%= end_tabnav %>Sounds cool? keep reading…
Where does the start_tabnav gets informations for tabs rendering? The :main Symbol let the start_tabnav method know to look for a special MainTabnav class where all the magic happens, so in my model directory I’ve got a main_tabnav.rb file containing something like:
class MainTabnav < Tabnav::Base
add_tab do
named 'Dashboard'
titled 'Wooooow! what a wonderful tabbed navigation!'
links_to :controller => 'dashboard'
end
add_tab do
named 'Users'
links_to :controller => 'users'
end
add_tab do
named 'Companies'
links_to :controller => 'companies'
highlights_on :controller => 'dashboard', :action => 'statistics'
end
add_tab do
named 'Admin'
links_to :controller => 'companies'
show_if "params[:admin] == true"
end
endThis way you can manage your tabs in a view-indipendent manner. The MainTabnav class should be pretty self-explanatory… but let me point out a few nice features:
- The titled method gives your tabs a html ‘title’ attribute so you can have tooltips over your tab link.
- The links_to method creates the tab’s link. You can use the same options as the usual ActionView’s url_for. The tab will be automatically highlighted (with the help of a CSS class) if the page you’re viewing matches the links_to options. So if you’re linking to :controller => ‘dashboard’, you can be sure every dashboard’s action will keep the tab highlighted. If you’re linking to :controller => ‘dashboard’, :action => ‘index’ only the index action will highlight it.
- You can add more highlighting rules using the highligths_on method. This could be useful if you have more than one controller that should highlight the same tab (eg: think about an estimate wizard involving multliple controllers, keeping an ‘estimates’ tab highlighted).
- You can conditionally choose to show or not show a tab given a certain condition with the show_if method. The string parameter given will be evaluated in the view context, so you can show admin pages tabs only to administrators and so on.
It’s cool! Tell me how to use it!
Install it from your rails base directory with this: ruby script/plugin install svn://svn.seesaw.it/tabnav/tags/0.1
And generate how many tabbed navigations you like with:
ruby script/generate tabnav Main
Of course you can substitute ‘Main’ with the desired prefix of your tabnav class.
Then configure your Tabnav model as you desire and include a start_tabnav/end_tabnav statement in your layout or view files.
Can I customize the generated HTML/CSS?
The tabnav generator will create a partial file inside your view/tabnav directory. There you can customize the html and the inline CSS used by your tabnav. You can move the inline CSS to you stylesheet file too.
Can I nest navigations?
Yes of course, with tabnav you can easily do something like:
Another little trick…
Last but not least you can have tabbed navigations without having a whole ‘containing box’ using just a:
<%= tabnav :main %>This way you can do stuff like:
That’s it right now guys. Hope you find it useful! Don’t forget we need feedback, so feel free to comment on this post or send us a private email.
If you want to keep in touch with further developments you can even subscribe to our rss feed.
This plugin is part of the SeeSaw’s toolbox.
having trouble downloading the plugin? You can install it without subversion:
In vendor/plugins, create directory tabnav. In that directory download end extract this!
Update: Due to a server migration, we’ve moved our repositories to a new location… see this for more info.







i can’t install it to my operation system. my operation system is windows 2003. please help me. thank you. this tool is very very cool!
Nice plugin,
keep up the good work!
Hi, I would like to use tabnav in my app but your svn server is down for second day at least. Any chance you can make it available somehow?
Thanks.
Zeljko
It is working right now and we haven’t noticed any downtime so far. Are you sure you’re not behind a firewall or have configuration issues? Anyways we’re setting up a .tar.gz version available via this blog. Leave your email. and I’ll send you the packaged version ASAP
Thanks. Please, please send me and I will check right away why I can’t get it. Anyone else have such issues?
Again thanks a bunch.
Zeljko
Nice tool!
Got it working immediately! But how can i use it with grouped controllers? I tried
Links correct, but does not highlight… Moreover, if i´ve been at /admin/infos/somewhere and use a tab to return to /user/anotherone it creates the url /admin/user/anotherone…
Please tell me it is possible anyway and i´ve made sth wrong…
Cool plugin. I have it installed and generated a menu named administration but when I add the code above to my layout file, I’m getting this error:
undefined method `start_tabnav’
What did I do wrong?
[Peter] I’ve never tried to use it with grouped controllers, and I’m not familiar with them. Try to add an highlights_on :controller => ‘infos’ I’ll dig this issue but if you want take a look into my code and see if something looks wrong.
[Kyle] try to restart your app, this plugin does not support hot reloading yet.. it’s in my todo list :-)
Thanks, restarting the app did the trick. Great plugin. Thanks again.
I’ll retiterate that the plugin is great. Maybe a note about the lack of reloading, causing it tripped me up a bit as well! Definitly made a little app I am working on look sharper!
I just want to thank you guys for creating this plugin. It is time saver and great helper. It does help when you know in advance about how it works, as I couldn’t use it in my app as all tabs use same controller,action pair. Still, I already have idea how this will be great to use in future projects. I also want to thank you for helping me obtain it.
Keep up the good work.
Zeljko
I faced the same problem as Peter, using the controller nested in a module.
I struggled around with link_to, finally I found out it’s only necessary to add the controller with the module name as a highlight again:
links_to :controller => ‘companies’ highlights_on :controller => ‘mymodule/companies’
this works for me, as I’m using the menu only inside the module. Propably this workaround won’t do it if the menu shows up on a page outside the module.
Thanks that worked perfectly for me
Lovely Plugin Paulo, thanks :)
Is there any way to get the plugin from a http source? I have no access to SubVersion repositories from this location. Thank you Lucas
You should be able to download it via http here.
A tab like add_tab do named ‘AnyName’ links_to :controller => ‘cursos’ end
links to /
Any other string not been ‘cursos’ works.
Anybody can verify this works or not?
I set it up, but all I see is Home>
class MainTabnav < Tabnav::Base add_tab do named ‘Home’ links_to :controller => ‘account’ end end
Also, inside _main_tabnav.rhtml, the ‘tabs’ array only contains one object:
tabs.each do |tab|
Please help!
Thanks, Mark
[Mark] Code must be:
class MainTabnav < Tabnav::Base
add_tab do
named ‘Home’
links_to :controller => ‘account’
end
#MOVED THE END FROM HERE…
add_tab do
named ‘Products’
links_to :controller => ‘products’
end
add_tab do
named ‘Categories’
links_to :controller => ‘categories’
end
end #...TO HERE
Hi,
I ran the plugin install script: $ ruby script/plugin install svn://svn.seesaw.it/t abnav A /var/www/helpdesk/vendor/plugins/tabnav A ... /var/www/helpdesk/vendor/plugins/tabnav/README Exported revision 38.
...seemed to work ok. But when I try to generate, I get:
./script/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:147:in `require’: no such file to load—rubygems (MissingSourceFile) from ./script/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:147:in `require’ from script/../config/../vendor/plugins/tabnav/init.rb:1:in `load_plugin’ from ./script/../config/../vendor/rails/railties/lib/initializer.rb:348:in `load_plugin’ from ./script/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings’ from ./script/../config/../vendor/rails/railties/lib/initializer.rb:348:in `load_plugin’ from ./script/../config/../vendor/rails/railties/lib/initializer.rb:158:in `load_plugins’ from ./script/../config/../vendor/rails/railties/lib/initializer.rb:158:in `load_plugins’ from ./script/../config/../vendor/rails/railties/lib/initializer.rb:102:in `process’ from ./script/../config/../vendor/rails/railties/lib/initializer.rb:42:in `run’ from ./script/../config/../config/environment.rb:13 from ./script/../config/../vendor/rails/railties/lib/commands/generate.rb:1 from script/generate:3
...is there some missing dependancy that needs to be installed beforehand? Im using:
Ruby version 1.8.4 (i486-linux) Rails version 1.1.2
Thanks,
Justin
In fact, tabnav apparently poisoned the plugin init process to the point where I could no longer fire up the server.
$ => Booting WEBrick… ./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:147:in `require’: no such file to load—rubygems (MissingSourceFile) from ./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:147:in `require’ from script/../config/../vendor/plugins/tabnav/init.rb:1:in `load_plugin’ ...and so on
Deleting tabnav directory fixes the problem. $ rm -rf tabnav $ => Booting WEBrick… => Rails application started on http://0.0.0.0:3000 ...
In vendor/plugins/tabnav/init.rb:
require ‘rubygems’
require ‘active_support’
require ‘action_view’
require ‘tabnav_core_extensions’
require ‘tab’
require ‘tabnav’
require ‘application_helper_extension’
For message no such file to load—rubygems(MissingSourceFile), it seems you haven’t install rubygems??
Must be installed all require in init.rb
Hi,
I am running on edge rails. As of today, my app broke and is failing on tabnav. It was working fine before… ???
The strange thing is, when I start mongrel server, I can load any page in my app one time. Then, if I reload or go to a new page it fails immediately until I restart the web server.
I renamed the vendor/rails edge rails dir to rails_foo and restarted the web server and I can view pages with no problem with tabnav (primary rails is 1.1.5 as of today and this works).
Here is the stack trace first showing the successful load (controller => about), and then the failure (controller => about, action => beta):
Here is the main error:
ActionView::TemplateError (undefined method `tabnav’ for #<#:0×3847a58>) on line #5 of app/views/layouts/_main_menu.rhtml: 2: 3: 4: <!- TABNAV : Start inclusion of TabNav Tab Menu RoR plugin -> 5: <%= tabnav :main %> 6: <!- TABNAV : End -> 7:
Here is the trace for when it fails:
ActionView::TemplateError (undefined method `tabnav’ for #<#:0×3847a58>) on line #5 of app/views/layouts/_main_menu.rhtml: 2: 3: 4: <!- TABNAV : Start inclusion of TabNav Tab Menu RoR plugin -> 5: <%= tabnav :main %> 6: <!- TABNAV : End -> 7:
Rendering C:/Data/subversion/rubyrails/packmaps/trunk/packmaps/config/../vendor/rails/actionpack/lib/action_controller/templates/rescues/layout.rhtml (500 Internal Error)
Hello thanks for the plugin. Unfortunately, it’s not working for me
“ruby script/plugin install svn://svn.seesaw.it/tabnav”
says it installs (as in no errors) but there is no feedback of any kind, either.
Then “ruby script/generate tabnav Main”
says, Couldn’t find ‘tabnav’ generator.
?? Tried restarting server. No go. thanks.
sorry, newbie. Do I need to install something to get svn:// from plugins command?
Answered my own question. Yes, I do. :)
thanks…
hmm… want to share what this “something” was that you had to install, enric? :)
Hi Paolo!
Very nice plugin! Is it possible to arrange tabs vertically on the left/right side of main_content area?
How can I do it?
Sure you can! Tabnav is just a list of <li> element, any layout customization can be made via CSS like any other html list.
Great! I’ll keep playing around :)
Two questions -
1- I have 2 types of users for my app. I’d like one tabnav set for the first type of user and another tabnav for the second type of user. Is this possible ? In other words each user has different functions available to them.
2- Should / could I treat each tab as a div where within would like either an rhtml view or partial / or rjs page ?
TIA Stuart
[1] Yes, just using a proper boolean condition with show_if in the model file; something like:
add_tab do named 'Admin' links_to :controller => 'companies' show_if "params[:admin] == true" endTake a look at the second code fragment of the original post.
[2] Actually tabs are rendered like an HTML list, but you easily use another behaviour redefining the partial in /app/view/tabnav/.
Hi Guys,
Is there a way to use TabNav and not put it in the layout?
It seems like you would have to be able to do that to be able to do the nesting of tabs.
Thanks
Gareth
Hi Michele,
I was trying to work out a way to dynamically add tabs. For example, if you had a portfolio tab which was a menu list of all your portfolio entries, you might want to iterate through all the entries, but the options for each tab as essentially the same.
Maybe an add_collection_of_tabs method could work well.
However, I have managed to get the same functionality to work with the current plugin code:
So just as a suggestion, perhaps you should add some sort of method which allows people to add a collection of tabs.
Thanks for the useful plugin, David.
Neat job! I wish the salted passwords gen was this easy to install ;) BTW, if you use WEBrick you need to restart the server to see the changes you make in the MainTabnav class. But that’s as much surprises as you can get :)
This is what I am trying to do in my current project. Thanks Paolo, I am going to use this plugin.
I just downloaded the Plugin from the http source and unzipped on a Mac to a TabNav folder. Where do I place this folder or wht else do i need to do to get it working.
How to make rounded tabs using this plugin
How can I highlight tab through RJS?? Any Idea????
Hi I am not able to access the svn server . At least I get no message from the script\plugin
Regards Hari
Sorry for the dalay of this answer but we had huge problems with spam filters during these days.
[for umang@mac.com + Hari]
Installation of the .tar.gz/.zip is very basic: decompress the archive into the vendor/plugins/ directory of your rails project and follow the tutorial .
[for Akhil Bansal]
Rounded tab can be obtained using CSS/HTML: take a look to the answer to the Stuart’s problem, 9/10 post ago. Do you really need RJS? ;-)
[for Bèrto ‘d Sèra]
Thank you so much!
I’m having trouble figuring out how to implement Tabnav in my fledgling app.
I have a main page which I do not want to convert to tabs. But when I go to edit, say, a person record or a pets record, I want a tabbed form to open with a separate clump of info to edit on each tab. The person edit would open up a set of person-related tabs, and the pet edit would open up a set of pet-related tabs.
I have a layouts/application.rb but putting the start_tabnav and end_tabnav there cause multiple sets of the same tabs to appear. I could make copies of the application.rb and just change the start_tabnav line of each to point to the correct set of tabs for that table. But that wouldn’t be very DRY, would it?
So how do I specify a layout for person that can have <%= start_tabnav :main %> <%= @content_for_layout %> <%= end_tabnav %> but still use application.rb as a wrapper?
Thanks…
Yes, I still need to highlight tabs in RJS Calls… How could i do that…....
Thanks for your plugin
… is it possible to rename the tabs to support different languages?
… is it possible to rename tabs to support different languages?
How Can i have 2 or more conditions for “show_if”.
Regards, Ashwin
Can I include an :id tag that populates dynamically? I’ve been able to include a hardcoded id without any problems, but when I include a variable from my controller, it is not being populated.
Thanks,
David
[Ashwin] How can i specify 2 or more conditions using “show_if”?
Just try with:[Peter Salomon] is it possible to rename tabs to support different languages?
Right now it’s not possible by the plugin itself. Take a look to i18n tools for Rails and try to apply them on the Tabnav code. PS: don’t forget to let us know what you’ll discover ;-)
[Akhil] highlight tab through RJS?
You can set the CSS class of an HTML element via RJS/prototype calls, just set the CSS class to ‘active’ on the dom id you need to highlight.
I’m getting the same ‘undefined method’ error in my rails app.
The ApplicationHelper methods don’t seem to get loaded. If I drop them directly into application_helper.rb it works just fine. I’ll look into it later.
Hi Paolo, nice stuff
Anyway, I have tried for hours to set the @name var accordingly to the highlighted? method.
So, what I would need is to set a different name if the tab is highlighted.
Any atempt so far resulted in some strange “error”, that way, that the @name got changed, but once a given menutab clicked, the name stayed changed…
Actually what I need is the following:
instaed of just having a class=”xyz” for the a-tag, what I would like to have is a kind of wrapper around the “name”, e.g. name and on highlight name
So, as the url_for / link_to etc methods dont offer this kind of stuff i pass this directly within the @name var..
Any simple way to get this running ???
Regards
matthi
We’re working on dynamic names, titles, links etc. This way you will able to pass a Proc object to named, titled,... Just have a little bit of patience as we’re buried by another project right now.
Paolo
When I run this within the app’s root directory “ruby script/plugin install svn://svn.seesaw.it/tabnav” it appears to install correctly because I see no errors or warnings. Just a blank prompt. But when I try to do this “ruby script/generate tabnav Main” from the app root, I get “Couldn’t find ‘tabnav’ generator” ???
After downloading the tar and unpacking it in the vendor/plugins directory, then calling generate it worked. Something must be wrong with the install command line and the url.
Do I really have to restart every time Webrick after Tabnav-Model-Changes?
Hi, Is this work with named URL’s. I tried this: add_tab do named ‘Home’ links_to home_url end
It not worked. Is there any work around for that.
Great plugin. But one question:
How do I have the link contain parameters. So for example if I have a Order Tab that shows an order how do add the order Id to the tab so when when it is clicked I can get the id.
Thanks
I figured it out. I just changed the generated template to change the link parameter to add the params I needed.
We’re about to release a new version of the plugin that supports dynamic parameters. I cannot do it right now because we’re moving the svn to a new server, but I promise we’ll do it in a few days.
[marco] Yes you have to restart the container, I have no time to fix the reloading issue but if you want to dig into it and submit a patch I’ll appreciate it for sure! The same goes for named routes.
Is the new version is restful?
The link to download the tabnav code on your website does not work – it times out. Also, the svn does not seem to work for me either. I have never been able to get the svn to work, but I have gotten the download to work before. Is it down?
As you can see in this post, we are migrating our servers… public svn repo is ready to use while the archives are not. Thank you for your patience!
I’ve got navtabs working – sortof – pretty cool actually. My problem is I have a header with logo that displays (using a css header), then the NavTabs, then my content. In between the header and NavTabs, then again between NavTabs and main content there is whitespace. I do not have any of these things set with margins in my css file. What else am I missing? I’d like to Tabs to butt up against my header and have my main content start right below that! Any ideas?
You probably should edit the generated css file under
app/view/tabnav/_your_tabnav.rhtml.There are margins set there.
Yeah I thought it was going to take me at least 10 minutes to find and implement a tab-solution to a big ole rails project at my company. It took me 3, I am going to go have a cigarette with the spare 7. Sweet.
Merry Xmas to all readers…
Super plugin… easy to install and to use ..but I’ve been searching around how to pass au :id in the link wo any success… (finally hacking it with a session variable.. but not very RoR…)
so it’s stil an open issue for me :
in my view how to pass the @user as an id ? <%= start_tabnav :profil %>
to get it in the profil_tabnav.rb links_to :controller => ‘profils’, :action => ‘show’, :id => @user
as my action ‘show’ needs an :id…
thanks for your lights
kad
Try with:
links_to proc {{:controller => 'profils', :action => 'show', :id => @user}}hi, thanks for the great plugin, the trick with links_to proc{{.... for dynamic links doesn’t work for me, is there any other workaround? that would be great,
what error are you getting? are you using the latest version?
links_to proc
working well…. thanks a lot ! great plugin saving time !!
TabNav blew up my computer. Awesome TabNav ! Little things like this allow me to focus on the enjoyable aspects of programming like writing “synchronized dual turbo server blitzing.” Or as it’s acronymn SDTSB.
So, I am trying to embed tabs, I am using
class CustomerTabnav < Tabnav::Base add_tab do named 'Info' links_to proc {{:controller => 'profils', :action => 'show', :id => @user}} end endand my tabs dissapear. If I use: as my link, it works. However, I do need the ID and don’t understand what I am missing…. Any takers?Now, I’m closer with:
add_tab do named 'Overview' links_to {{ :controller => 'customers', :action => 'show', :id => @customer }} end add_tab do named 'Info' links_to {{ :controller => 'customers', :action => 'show_info', :id => @customer }} endbut all of my links in my html point to: when you can see in my links_to definitions, I pointed them to different places.Note to those who follow:
thus, instead of the svn import command above, save yourself the grief and days of troubleshooting, and use this svn instead:script/plugin install svn://svn.seesaw.it/tabnav/trunkupdating to 1.2.1 from 1.1.6 crashed my application, I am usign tabnav for a tabbed navigation, without container or stuff…
Is there anything i have to change for 1.2.1 ??
undefined method `tabnav’ for #<#:0×4dab278>
There has never been a prob under 1.1.6
I will figure it out, just am asking in case you came to the same prob before and could help me and probably others out
Anyway, very nice puligin
keep on the good work matthibcn
ps: would be nice if this comments would be DATED instead of using “150 days later”, “180 days later”...
Hi! I’m trying to use this on a display page for books.
The tabs are part of the overall page, and a way to avoid cluttering the page with all the information about the book in one big chunk.
So, I’ll have three tabs, “Description”, “Table of Contents”, and “Reviews”.
All link to the same action, like:
Only thing is, the :show => parameter works fine, and the page is redrawn properly, displaying the right tab.
Except: All tabs are of the “active” class, because the links_to points to the same action in the same controller.
I’d like an option like, highlights_on_and_only_on { myproc }, so that I can have just one tab use the “active” class.
Do I make any sense?
Thanks for a nice plugin! :)
Ah! Got it!
It should be,
highlights_on :show => ‘description’, :show => nil
Cheers :)
Anyone know what causes this: /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:376:in `new_constants_in’: You have a nil object when you didn’t expect it! (NoMethodError) You might have expected an instance of Array. The error occurred while evaluating nil.empty? from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:202:in `load_file’ from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:94:in `require_or_load’ from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:248:in `load_missing_constant’ from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:452:in `const_missing’ from script/../config/../vendor/plugins/tags/acts_as_attachment-1.1.6/init.rb:6:in `load_plugin’ from /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/initializer.rb:401:in `load_plugin’ from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings’ from /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/initializer.rb:401:in `load_plugin’ ... 15 levels… from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:495:in `require’ from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:342:in `new_constants_in’ from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:495:in `require’ from script/generate:3
Found the culprit:
`const_missing’ from script/../config/../vendor/plugins/tags/acts_as_attachment-1.1.6/init.rb:6:in
Hey! Where can I download the right version for rails 1.1.x using http?
I’ve just updated the download page with the new versions
Using IE7 with tabnav, the tabs float about 10 pixels above the content box. Using FF or IE6, all is fine. Anyone else seeing this?
I’ll keep playing around :-) Thanks!
I am here to notify you that in the end of April 2007 will be Ruby and WP community party at NY, US.
I’m not able to make it work. I’m using InstantRails. Its giving me ‘undefined method `start_tabnav’ for #<#:0×47cc758>’ error. I’ve extracted the tar file under vendor/plugins dir of my app. Please help !!!!
I managed to get it up running but facing new problem. How to use ‘links_to’ to specify the content div as watever :action i’m setting rite shows up the content on new page without the tabs?
Hi, after adding the appropriate link_to, the tabs disappear after selection.
Hi, I was thinking that it would be cool if I could simply use render instead of links_to. I say this because I want to do is render content for a tab. What do you think about this?
Hi, Thanks for such a great plugin. I have been trying to dynamically add a tab into the tabnav. What user does is, clicks on a link on a page, this should rout the resquest to an action in a controller. This action should have the logic to dynamically create a control. Now had some success with this, I did something like this:
def show @group = g = Group.find(params[:id]) ListTabsTabnav.add_tab { named g.name; links_to :controller => “groups”, :action => “show”, :id => g.id } end
This works fine as long as FastCGI is not on. When I put my app on FastCGI, problems begins. Once the tab is dynamically created it just stays there forever. Even if i change page. I have to kill the fcgi dispatcher, to remove it.
Is there some better way to handel this problem?
to “peter Salomon”... with grouped controllers
just use
add_tab do named ‘Albums’ links_to :controller => ‘admin/albums’ end
without starting ”/” in links_to .. it works :)
this plugin is pretty cool but I have a bit of a problem.
I want the ability to assign the list item with the class ‘active’ as well when I indicate highlighting. I need this so my tab looks cool when highlighting as i’m doing the curvy image thing.
Not sure how i could do that without hacking your code.
Thanks
nice plugin! I wonder if it would be possible to add a image next to each tab-title? First try was to modifythe html-list-tag in …_tabnav.rhtml like this:
didn’t work so far, am not that experienced with rails or html :-(
Anyone has a idea how to make it work?
Thanks
hum? last comment seemed to miss the code:
“
“
hmm ok, this seems not loving to embed html-tags, so third try without tags: ul id=”order_tabnav” style=”list-style-image:url(/images/list_icon.gif)”
:-)
My project requires rounded tabs, so I’m trying to modify the default views.
The generated rhtml partials appear to be empty (other than a comment).
I’ve added code to the partials, but the partials are not having any effect. Nor are they even being called.
How do I change from a simple list to something of my own devising?
Hi there,
after generate a tabnav inside a folder:
#./script/generate tabnav dir/model
when a i call it in the view, like this:
start_tabnav :model
after that, this error appears:
/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:477:in `const_missing’: uninitialized constant Symbol::ModelTabnav
this worked in the previous version, because i tested…but in the 1.2 it doesn’t work in the same way…
how do i call a tabnav, that is inside in a directory with the new tabnav version (1.2)?
I’m new to Rails, but this plugin is going to save me a lot of work. Thanks for putting this together.
I need to pass in an id to build the links for each tab. How does one reference request parameters from the TabNav extension class?
Nevermind. I got it working from one of the commments above. Thanks.
Hi. How to highlight tab with more then one controller? Sth like highlights_on :controller=> ‘admin/one’, :controller => ‘admin/two’ ?
What’s this plugin have over the one liner tab helper described in http://www.vaporbase.com/postings/A_tab_helper_that_works_for_me ?
Yeah this plugin didnt work for me. Acted like it installed just fine, but when i ran the generator, got a “Couldnt find tabnav generator” error message! Keep up the good work guys
I’ve the same problem that Jignesh, matthibcn, Michiel, ...
undefined method `tabnav’ for #<#:0×4789cb4>
Do you know de solution?
thanks,
ern.
This is a great plugin! Have you thought about creating one for ajax hooks?
I want student name in top of page & tabs like edit & show with that students id
try to work with proc but gives an error
Showing app/views/tabnav/_student_tabnav.rhtml where line #61 raised
:You must set a page before calling this method
(error on line #61 )
58:
<% 59: tabs.each do |tab| 60: html_opts = {} 61: html_opts[:class] = ‘active’ if tab.highlighted?(params) 62: html_opts[:title] = tab.title if tab.title 63: if eval(tab.condition) -%> 64:- <= link_to tab.name, tab.link, html_opts ->
<%
Trace of template inclusion: /app/views/student/tabs.rhtml
My tabs page is
<%= tabnav :student %>
Please any one help me
Hi Guys,right now I am working on Tabs . I got them but I am having a problem in it. It is like this : whenever I click on the Tab it is navigating to the controller’s index method . Here I want the data of the Tab with respect to its clicking .And help me in writing the Actions with respect to Tabs. Hope you all understood my problem and please help in fixing this .
Thanks & regards , Manohar manoharkundety@gmail.com
[marco and paolo]
You can reload the tabnav.rb file without restarting the server the same way you reload models, by simply adding “include Reloadable” to it…
class ExampleTabnav < Tabnav::Base include Reloadable
end
Of course that only works in the development environment. I ended up having to just do the dynamic tabs manually. Sorry, didn’t have time to go in and figure it out this time…