Hello, I new to rails and even though I am working through the Agile Dev-Book I dont get this running: I set up a site (local) thats supposed to compare tents. So a tent can have a tent-type, cotton-color and so on. I need a few easy has_many- an belongs_to-connections. I build the scaffold-script for "zelttyp" and "zelt" (german for tenttype an tent) (ruby script/generate scaffold Tent_Type Zelttyp). My database has an table "tents" with a row "type_id" in it. I think this is not right because the name-conventions is looking for a row "tent_type_id", right? - So I added this as well but the problem is the same. There is also an foreign key named "fk_tenttype_tent" that shows "type_id -> tent_types.id". And there is this tent_types-Table Everything is running so far. Now I add the has_many class ZelttypController < ApplicationController has_many :tent #scaffold-code follows end The result: ##NoMethodError in <controller not set>#<action not set> undefined method `has_many'' for ZelttypController:Class /app/controllers/zelttyp_controller.rb:4 routing.rb:219:in `traverse_to_controller'' generated/routing/recognition.rb:3:in `eval'' generated/routing/recognition.rb:3:in `recognize_path'' This error occured while loading the following files: ./script/../config/../app/controllers/zelttyp_controller.rb The same happens for the file zelt_controler.rb when adding belongs_to :tent_type I am pretty shure it''s not that difficult but somewhere there lies a stone in my way =(. Regards ~Tobias -- Weblog: http://flyingsparks.wwwfiles.de/
Tobias Jordans wrote:>Hello, > >I new to rails and even though I am working through the Agile Dev-Book I >dont get this running: > >I set up a site (local) thats supposed to compare tents. >So a tent can have a tent-type, cotton-color and so on. >I need a few easy has_many- an belongs_to-connections. > >I build the scaffold-script for "zelttyp" and "zelt" (german for tenttype >an tent) (ruby script/generate scaffold Tent_Type Zelttyp). > >My database has an table "tents" with a row "type_id" in it. I think this >is not right because the name-conventions is looking for a row >"tent_type_id", right? - So I added this as well but the problem is the >same. >There is also an foreign key named "fk_tenttype_tent" that shows "type_id >-> tent_types.id". >And there is this tent_types-Table > >Everything is running so far. >Now I add the has_many >class ZelttypController < ApplicationController > has_many :tent > #scaffold-code follows >end > >The "has_many" belongs in the model definition not the controller definition.
Also, it''s "has_many :tents". On 9/17/05, Steve Downey <sldowney-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> wrote:> > Tobias Jordans wrote: > > >Hello, > > > >I new to rails and even though I am working through the Agile Dev-Book I > >dont get this running: > > > >I set up a site (local) thats supposed to compare tents. > >So a tent can have a tent-type, cotton-color and so on. > >I need a few easy has_many- an belongs_to-connections. > > > >I build the scaffold-script for "zelttyp" and "zelt" (german for tenttype > >an tent) (ruby script/generate scaffold Tent_Type Zelttyp). > > > >My database has an table "tents" with a row "type_id" in it. I think this > >is not right because the name-conventions is looking for a row > >"tent_type_id", right? - So I added this as well but the problem is the > >same. > >There is also an foreign key named "fk_tenttype_tent" that shows "type_id > >-> tent_types.id". > >And there is this tent_types-Table > > > >Everything is running so far. > >Now I add the has_many > >class ZelttypController < ApplicationController > > has_many :tent > > #scaffold-code follows > >end > > > > > > The "has_many" belongs in the model definition not the controller > definition. > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails