rw-F6bCd2kFQHs@public.gmane.org
2005-Apr-11 20:37 UTC
how can i query a submit button in a controller method?
hi, i''m new to rails read gone thru all tutorials and trying to make my very first real-app-thing with rails. basic stuff works ok. now i''m having a form with 2 (two) submit buttons one named submit and the other txt2html edit.rhtml: <input name="submit" type="submit" value="Edit" /> <input name="txt2html" type="submit" value="mach html" /> messages_controller.rb: since it doesn''t seem to be possible (why for rails'' sake?) to have a <input type="button"> or <input type="submit"> assigned to a controller action, i try to handle that in the update method: def update @message = Message.find(@params[:id]) # debug @params ---> this won''t work # p @params --->works for webrick-log but server servers a # nearly blank page ##<RuntimeError: bad header ''"{\"message\"=> ##{\"body_txt\"=>\"alles horsti hi!\", \"body_html\"=>\"\", ##\"title\"=>\"tach auch\", \"newsletter_id\"=>\"2\"}, ##"action\"=>\"update\", \"id\"=>\"2\", # #--->here it is!! \"txt2html\"=>\"mach html\", # ##\"controller\"=>\"messages\"}\n"''.> if @params[:message][:txt2html].to_s==''mach html'' then # condition is false # also nothing happens here: # if @params[:message][:txt2html] # if @params[''message''][''txt2html''] # if @params[''message''].has_key?(''txt2html'') # @message.attributes=@params[:message] @message.tohtml @newsletters = Newsletter.find_all flash[''notice''] = ''a html version was created. nothing was saved. press -edit- to save'' render_action ''edit'' else if @message.update_attributes(@params[:message]) flash[''notice''] = ''Message was successfully updated.'' redirect_to :action => ''edit'', :id => @message else @newsletters = Newsletter.find_all render_action ''edit'' end end end -------------- i think i''m having a blackout here..?? btw. how can i friendly debug in controller methods? greetings, robert
rw-F6bCd2kFQHs@public.gmane.org
2005-Apr-11 20:48 UTC
RE: how can i query a submit button in a controller method?
to answer my own question (blackout partially over): @params[''txt2html''] works fine! ough! --robert on 2005-04-11 22:37:51 you wrote:>hi, > >i''m new to rails read gone thru all tutorials and trying to make my >very first real-app-thing with rails. basic stuff works ok. > >now i''m having a form with 2 (two) submit buttons one named submit and >the other txt2html > >edit.rhtml: ><input name="submit" type="submit" value="Edit" /> ><input name="txt2html" type="submit" value="mach html" /> > >messages_controller.rb: > >since it doesn''t seem to be possible (why for rails'' sake?) to have a ><input type="button"> or <input type="submit"> assigned to a controller >action, i try to handle that in the update method: > >def update > @message = Message.find(@params[:id]) ># debug @params ---> this won''t work ># p @params --->works for webrick-log but server servers a ># nearly blank page >##<RuntimeError: bad header ''"{\"message\"=> >##{\"body_txt\"=>\"alles horsti hi!\", \"body_html\"=>\"\", >##\"title\"=>\"tach auch\", \"newsletter_id\"=>\"2\"}, >##"action\"=>\"update\", \"id\"=>\"2\", ># >#--->here it is!! \"txt2html\"=>\"mach html\", ># >##\"controller\"=>\"messages\"}\n"''.> > > > if @params[:message][:txt2html].to_s==''mach html'' then ># condition is false ># also nothing happens here: ># if @params[:message][:txt2html] ># if @params[''message''][''txt2html''] ># if @params[''message''].has_key?(''txt2html'') ># > @message.attributes=@params[:message] > @message.tohtml > @newsletters = Newsletter.find_all > flash[''notice''] = ''a html version was created. nothing was saved. >press -edit- to save'' > render_action ''edit'' > else > if @message.update_attributes(@params[:message]) > flash[''notice''] = ''Message was successfully updated.'' > redirect_to :action => ''edit'', :id => @message > else > @newsletters = Newsletter.find_all > render_action ''edit'' > end > end > end > >-------------- > >i think i''m having a blackout here..?? btw. how can i friendly debug in >controller methods? > >greetings, > robert > > > > > > > > >_______________________________________________ >Rails mailing list >Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >http://lists.rubyonrails.org/mailman/listinfo/rails