ruby on rails - how to create a migration that will populate my menu -
how create migration populate menu. example have relationship survey has_many :question , question belongs survey question has_many :answers, , answer belongs question
this relationship have , have data driven menu menu survey , under survey there questions. menu this
survey1 *question1 *question2 survey2 *question1 *question2
any ideas??
i did this, so...
step 1. use acts_as_tree create tree-structured menu.
step 2. create tree structure in seeds.rb can rake db:seed
about_us = root.children.create(:title => 'about us') {|r| r.url = '/pages/about_us'} about_us.children.create(:title => 'biography') about_us.children.create(:title => 'our clients') about_us.children.create(:title => 'office locations') about_us.children.create(:title => 'contact us')
step 3. create helper in application_helper.rb (or wherever) build menu out in html.
Comments
Post a Comment