Babak bsn
2011-Sep-06 20:02 UTC
Is it possible to manage multiple non-related Models from a Rails form?
my project is about German language( that save the German words). I have three Tables (Word for Nammen, Adverb for adverbs,Adjektiv for Adjectivs and Adverb for Adverbs) of course in my scnario(thst is not optimal) there is no realation between Tables.I have one form that user can add adverb OR adjective or....(see:http://babakbsn.persiangig.com/UI12.png)i use accordion and each one has a tab in accordion i want to give a possibility to user to edit one record in that page.but when the user click on a record to edit,another records with the same ID too appear in another tabs(see:http://babakbsn.persiangig.com/UI12.png) how can i avoid that? this is my controller: class WordsController < ApplicationController def new @word=Word.new @verb=Verb.new @adjektiv=Adjektiv.new @adverb=Adverb.new end def create @word=Word.create(params[:word]) @verb=Verb.create(params[:verb]) @adjektiv=Adjektiv.create(params[:adjektiv]) @adverb=Adverb.create(params[:adverb]) if @word.save || @verb.save || @adjektiv || @adverb redirect_to :action => ''index'' else render :action => ''new'' end end def index @word=Word.find(:all) @verb=Verb.find(:all) @adjektiv=Adjektiv.find(:all) @adverb =Adverb.find(:all) end def edit @word=Word.find(params[:id]) @verb=Verb.find(params[:id]) @adjektiv=Adjektiv.find(params[:id]) @adverb =Adverb.find(params[:id]) end def update @word =Word.find(params[:id]) if @word.update_attributes(params[:word]) || @verb.update_attributes(params[:verb]) || @adjektiv.update_attributes(params[:adjektiv]) || @adverb.update_attributes(params[:adverb]) redirect_to :action => ''index'' else redirect_to :action => ''edit'' end end end thank you for your help -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.