Returning from rails controller

后端 未结 3 519
长情又很酷
长情又很酷 2021-02-06 10:39

Here\'s a beginner rails question...

After I do:

format.xml { head: ok}

How do I return from the controller endpoint without showing th

相关标签:
3条回答
  • 2021-02-06 11:06

    I guess you must be asking for :

    render :nothing => true
    
    0 讨论(0)
  • 2021-02-06 11:16

    You can use "render :nothing => true, :status => :ok" to return without rendering anything, once you have send a render :nothing => true you need to return from the controller, something like this might work. You can swap the head() method call for a render => :nothing followed by a return, the head() method is documented here:

    • api.rubyonrails.org/classes/ActionController/Base.html#M000635

    Here's the code that should do it for you...

    • gist.github.com/126367

    Ping me if that doesn't properly answer your question, documentation for the render call with some helpful user comments can be found here:

    • apidock.com/rails/ActionController/Base/render

    (sorry I couldn't hyperlink the links for you, as a new user stackoverflow won't allow me to post more than one!)

    0 讨论(0)
  • 2021-02-06 11:17

    Use

    render :nothing => true, :status => :ok

    in your action method

    0 讨论(0)
提交回复
热议问题