在用户提交电子邮件后,我希望redirect_to slider_path
。 目前,只有成功的信息没有方向显示。 该法典:
class Splash::SubscribersController < ApplicationController
def create
@subscriber = Subscriber.new(params[:subscriber])
if @subscriber.save
success = true
message = "Success! We ll let you know when we launch."
else
success = false
message = "Fail."
end
respond_to do |format|
format.html {
if success
flash[:success] = message
redirect_to slider_path
else
flash[:error] = message
end
redirect_to root_path
}
format.json { render :json => { :success => success, :message => message }.to_json }
end
end
end