This is mostly a matter of opinion, but anyway: I would not want that much logic in a view. We've probably all done it, but it gets messy quickly The code is not safe against future changes that affect the depth of the tree Instead of linked variables name and link I'd suggest using proper objects anyway, with some link_to functionality You might find Episode 162 of Railscasts of interest for a nice solution that gets by with % for page in @page.ancestors. Reverse %.
This is mostly a matter of opinion, but anyway: I would not want that much logic in a view. We've probably all done it, but it gets messy quickly. The code is not safe against future changes that affect the depth of the tree.
Instead of linked variables *_name and *_link, I'd suggest using proper objects anyway, with some link_to functionality. You might find Episode 162 of Railscasts of interest for a nice solution that gets by with.
Breadcrumbs menu are a recurrent pattern in most Rails applications. To solve this issue, I created and released a plugin called breadcrumbs_on_rails. You define your breadcrumbs in the controller class MyController add_breadcrumb "home", root_path add_breadcrumb "my", my_path def index # ... add_breadcrumb "index", index_path end end and you render them in your view.
Untitled Even if you don't want to use a plugin, I encourage you to give it a look. It's open source and you can grab some idea for your app.
1 This is good, but breadcrumbs seem like a view responsibility instead of a controller responsibility. I'd recommend moving the add_breadcrumb method call to your view. – Ben Feb 17 '10 at 13:22 1 You can call the method in your controller as well in your view.
The controller allows you to define a per-controller navigation level to reduce code duplication in your views. – Simone Carletti Feb 17 '10 at 14:13.
Here is a plugin for creating breadcrumbs in Ruby on Rails: Ruby on Rails breadcrumbs plugin. The plugin is from my homepage. Example configuration: Gretel::Crumbs.
Layout do crumb :root do link "Home", root_path end crumb :projects do link "Projects", projects_path end crumb :project do |project| link project. Name, project_path(project) parent :projects end crumb :project_issues do |project| link "Issues", project_issues_path(project) parent :project, project end crumb :issue do |issue| link issue. Name, issue_path(issue) parent :project_issues, issue.
Project end end In your view: In your app/views/layouts/application.html. Erb: "You are here:", :separator => ">", :autoroot => true, :home_alone => true, :link_last => false %> Best regards, Lasse.
Here are two approaches: Split the URL and display it A more flexible solution implemented in the controller where you setup the breadcrumbs in the controller: Easy and Flexible Breadcrumbs for Rails.
BreadcrumbsOnRails is a simple Ruby on Rails plugin for creating and managing a breadcrumb navigation for a Rails project. It provides helpers for creating navigation elements with a flexible interface. X requires Rails 3.
Use BreadcrumbsOnRails 1. X with Rails 2. BreadcrumbsOnRails doesn't work with Rails 2.1 or lower.
RubyGems is the preferred way to install BreadcrumbsOnRails and the best way if you want install a stable version. Specify the Gem dependency in the Bundler Gemfile. Use Bundler and the :git option if you want to grab the latest version from the Git repository.
Creating a breadcrumb navigation menu in your Rails app using BreadcrumbsOnRails is really straightforward. In your controller, call add_breadcrumb to push a new element on the breadcrumb stack. Add_breadcrumb requires two arguments: the name of the breadcrumb and the target path.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.