After reading O'Reilly's "Ruby on Rails: Up and Running" chapter 5.6
about hierarchical categories, i decided to implement it to my
Basically i have a bunch of goods coming from different locations all
over the world.
I have created a table called locations that list all entries whether
its a country, a state, a department... This table implements the
concept of parenting.
id | name | parent_id
1 | USA | null
2 | France | null
3 | California | 1
4 | Riverside County | 3
5 | New York | 1
6 | New York City | 5
7 | Ile de France | 2
8 | Paris | 7
location.rb model looks like this:
class Location < ActiveRecord::Base
parent.ancestors_name + parent.name + ':'
ancestors_name + name
What I want to do is that instead of returning a basic long_name, each
level in the crumbs would be a link to the corresponding name.
Unfortunately, if i try to use link_to or render within the model, it
returns an error message saying the method is undefined.