I copied the scaffolding edit and update and made it like this, Note: awnser is edit. Admin_contoller.rb def awnser @question = Question.find(params[:id]) end def update @question = Question.find(params[:id]) if @question.update_attributes(params[:question]) flash[:notice] = ''Question was successfully updated.'' redirect_to :action => ''list'' else render :action => ''edit'' flash[:notice] = "Edit failed" end end Awnser.rhtml <h1>Awnsering question</h1> <%= start_form_tag :action => ''update'', :id => @question %> <p><%= @question.question %></p> <p><label for="questions_awnser">Awnser</label><br/> <%= text_area ''questions'', ''awnser'' %></p> <%= submit_tag ''Awnser'' %> <%= end_form_tag %> It flashes that it works but it really dosn''t change the question.awnser -- Posted via http://www.ruby-forum.com/.
Hi Mohammad, I might be misunderstanding your question but if, when your "Note" says ''awnser is edit'' you mean that you don''t have an ''edit'' aciton in your controller, then you might need to render :action => ''awnser'' instead of render :action =" ''edit''. hth, Bill ----- Original Message ----- From: "Mohammad" <name.goes.here44@gmail.com> To: <rails@lists.rubyonrails.org> Sent: Wednesday, April 26, 2006 11:21 AM Subject: [Rails] Not updating>I copied the scaffolding edit and update and made it like this, > > Note: awnser is edit. > > Admin_contoller.rb > > def awnser > @question = Question.find(params[:id]) > end > > def update > @question = Question.find(params[:id]) > if @question.update_attributes(params[:question]) > flash[:notice] = ''Question was successfully updated.'' > redirect_to :action => ''list'' > else > render :action => ''edit'' > flash[:notice] = "Edit failed" > end > end > > Awnser.rhtml > <h1>Awnsering question</h1> > > <%= start_form_tag :action => ''update'', :id => @question %> > > <p><%= @question.question %></p> > > <p><label for="questions_awnser">Awnser</label><br/> > <%= text_area ''questions'', ''awnser'' %></p> > > <%= submit_tag ''Awnser'' %> > <%= end_form_tag %> > > It flashes that it works but it really dosn''t change the question.awnser > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Bill Walton wrote:> Hi Mohammad, > > I might be misunderstanding your question but if, when your "Note" says > ''awnser is edit'' you mean that you don''t have an ''edit'' aciton in your > controller, then you might need to render :action => ''awnser'' instead of > render :action =" ''edit''. > > hth, > BillI did change this I thought that that would be it but, no that didn''t work it still thinks that it is updating it when its not, I made sure that there was no more typos for changing the names and there didn''t appear to be any. Im not sure what is going on. -- Posted via http://www.ruby-forum.com/.
Mohammad wrote:> Awnser.rhtml > <h1>Awnsering question</h1> > > <%= start_form_tag :action => ''update'', :id => @question %> > > <p><%= @question.question %></p> > > <p><label for="questions_awnser">Awnser</label><br/> > <%= text_area ''questions'', ''awnser'' %></p>That text_area needs to be ''question'', ''awnser'', singlualr question, not plural questions and if the db field is string, rather than text, it should probably be a text_field, rather than a text_area. Hope this helps, Alan -- Posted via http://www.ruby-forum.com/.
If you''d post your code, it''ll probably jump out at someone. If you do, please explain the problem you''re having again. Best regards, Bill ----- Original Message ----- From: "Mohammad" <name.goes.here44@gmail.com> To: <rails@lists.rubyonrails.org> Sent: Wednesday, April 26, 2006 2:59 PM Subject: [Rails] Re: Not updating> Bill Walton wrote: >> Hi Mohammad, >> >> I might be misunderstanding your question but if, when your "Note" says >> ''awnser is edit'' you mean that you don''t have an ''edit'' aciton in your >> controller, then you might need to render :action => ''awnser'' instead of >> render :action =" ''edit''. >> >> hth, >> Bill > > I did change this I thought that that would be it but, no that didn''t > work it still thinks that it is updating it when its not, I made sure > that there was no more typos for changing the names and there didn''t > appear to be any. Im not sure what is going on. > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Mohammad, You need to save the model after you update it. @question = Question.find(params[:id]) @question.update_attributes(params[:question]) if @question.save ... Mohammad wrote:> I copied the scaffolding edit and update and made it like this, > > Note: awnser is edit. > > Admin_contoller.rb > > def awnser > @question = Question.find(params[:id]) > end > > def update > @question = Question.find(params[:id]) > if @question.update_attributes(params[:question]) > flash[:notice] = ''Question was successfully updated.'' > redirect_to :action => ''list'' > else > render :action => ''edit'' > flash[:notice] = "Edit failed" > end > end > > Awnser.rhtml > <h1>Awnsering question</h1> > > <%= start_form_tag :action => ''update'', :id => @question %> > > <p><%= @question.question %></p> > > <p><label for="questions_awnser">Awnser</label><br/> > <%= text_area ''questions'', ''awnser'' %></p> > > <%= submit_tag ''Awnser'' %> > <%= end_form_tag %> > > It flashes that it works but it really dosn''t change the question.awnser >
Oops, I guess update_attributes does a save. My bad. Owen Stenseth wrote:> Mohammad, > > You need to save the model after you update it. > > @question = Question.find(params[:id]) > @question.update_attributes(params[:question]) > if @question.save > ... > > > Mohammad wrote: >> I copied the scaffolding edit and update and made it like this, >> >> Note: awnser is edit. >> >> Admin_contoller.rb >> >> def awnser >> @question = Question.find(params[:id]) >> end >> >> def update >> @question = Question.find(params[:id]) >> if @question.update_attributes(params[:question]) >> flash[:notice] = ''Question was successfully updated.'' >> redirect_to :action => ''list'' >> else >> render :action => ''edit'' >> flash[:notice] = "Edit failed" >> end >> end >> >> Awnser.rhtml >> <h1>Awnsering question</h1> >> >> <%= start_form_tag :action => ''update'', :id => @question %> >> >> <p><%= @question.question %></p> >> >> <p><label for="questions_awnser">Awnser</label><br/> >> <%= text_area ''questions'', ''awnser'' %></p> >> >> <%= submit_tag ''Awnser'' %> >> <%= end_form_tag %> >> >> It flashes that it works but it really dosn''t change the question.awnser >> > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > !DSPAM:444fbb7e151281175321214! >