Ruby on Rails: Action without View

后端 未结 4 1645
伪装坚强ぢ
伪装坚强ぢ 2021-02-14 13:48

I have what I think is a very simple problem. I\'m coming from a PhP background, and used to do this all the time, so I may be looking at this the wrong way.

I am trying

4条回答
  •  一个人的身影
    2021-02-14 14:16

    You'd need something like this:

    def mcsubscribe
      # Do something to unsubscribe
      respond_to do |format|
        format.html { redirect_to(success_page) }
        format.js   { render :text => params[:email] }
      end  
    end
    

    If ajax is used, the params[:email] is send as text. If a HTML format is required (ie user clicked a link or filled in a regular form) a redirect is issued to tell the user the subscription has been successful.

提交回复
热议问题