Hi all. After reading O''Reilly''s "Ruby on Rails: Up and Running" chapter 5.6 about hierarchical categories, i decided to implement it to my inventory application. 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 acts_as_tree :order=>''name'' def ancestors_name if parent parent.ancestors_name + parent.name + '':'' else "" end end def long_name ancestors_name + name end end 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. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
ljredpath-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Oct-27 22:57 UTC
Re: ActionController in Models, is it possible?
You can''t use link_to/render etc. because the model should know nothing about this. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---