Ok, This sounds like it should be easy but I am having a hard time with it. I am making a website but I''m trying to make everything in it fairly database driven, this is really pretty much my first rails project. I have a table called ''nav_items'' to display the nav choices, but there is also other dynamic data on the homepage such as the ''events'' which I''ve created a table for. So I want them to be both pulled into the homepage which is at http://localhost:3000/home on my system right now. So to get the data I create models ''events'' and ''nav_items'', don''t I need a controller for each to pull out the data? And when I call that controller (http://localhost:3000/nav_items) then it will take me away from home? Basically I''m looking to put all this data on one page without having to call 2 different controllers? I hope this all makes sense.
> > So to get the data I create models ''events'' and ''nav_items'', don''t I > need a controller for each to pull out the data? And when I call that > controller (http://localhost:3000/nav_items) then it will take me away > from home? >You dont need 2 controllers,you can access all the models from one controller. btw the model name is singular (thats the rails default) and the table name is plural.So i presume the database name is events and the model name is Event. So you can access them like this Nav_item.find(id) Event.find(id) both can be accessed from one controller. Vivek _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Thanks for the help again, I actually figured this out by stumbling around and figuring out the data wasn''t pulling properly because of how I had it named. It''s been a long day but I feel I am atleast learning :-)
in Controller of whatever name @x = model_1.find(:all) @y = modell_2.find(:all) Now you can manipulate and present the data as needed. In other words, one controller can make multiple calls to a model and store the data in an array. Does that answer your question? bruce On 5-Dec-05, at 12:45 AM, Jason Pfeifer wrote:> Ok, > > This sounds like it should be easy but I am having a hard time with > it. I am making a website but I''m trying to make everything in it > fairly database driven, this is really pretty much my first rails > project. > > I have a table called ''nav_items'' to display the nav choices, but > there is also other dynamic data on the homepage such as the > ''events'' which I''ve created a table for. So I want them to be both > pulled into the homepage which is at http://localhost:3000/home on > my system right now. So to get the data I create models ''events'' > and ''nav_items'', don''t I need a controller for each to pull out the > data? And when I call that controller (http://localhost:3000/ > nav_items) then it will take me away from home? > > Basically I''m looking to put all this data on one page without > having to call 2 different controllers? > > I hope this all makes sense. > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails