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

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -