开发者

how to print out values to the screen using flash ruby on rails

I created a scaffold dum num:integer name:string When I create a new dum, I wanted to use flash to print out the values of the number inputed into the form in the controller.

For example:

  • User enter the webbrowser
  • clicks create new dum
  • then enters the num and name then press submit
  • submit triggers the create开发者_JAVA百科 call in the controller

    def create @dum = Dum.new(params[:dum])

    respond_to do |format|
      if @dum.save
        flash[:notice] = 'Dum was successfully created.'
        format.html { redirect_to(@dum) }
        format.xml  { render :xml => @dum, :status => :created, :location => @dum }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @dum.errors, :status => :unprocessable_entity }
      end
    end
    

    end

Is there a way to print out the values in the flash function that is called to dispaly that the "Dum was sucesfully created". I thought

 flash[:notice] = '#{@dum}'

would work, but it only prints out the #.

This is probably a really simple question to answer, but for some reason cannot figure it out. Man purpose is to use this logic to debug with print statements of variables in the future. Unless there is a better way to debug a web app please let me know. In addition, how do you access the values grabbed from the form in here?

In the controller if i go:

@dum.num or @dum.name would that return me the input?

Thanks, Any Advice appreciated.


'#{@dum}'
^ Problem spotted

' != ". One does not interpolate, the other does.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜