wblog/app/controllers/unsubscribes_controller.rb

22 lines
448 B
Ruby
Raw Permalink Normal View History

2016-04-26 00:20:14 +08:00
class UnsubscribesController < ApplicationController
def index
end
def new
@subscribe = Subscribe.new
end
def create
2016-04-27 16:12:56 +08:00
subscribe = Subscribe.find_or_initialize_by(email: subscribe_params[:email])
2016-04-26 00:20:14 +08:00
subscribe.enable = false
subscribe.save
2016-04-27 16:12:56 +08:00
flash[:notice] = "退订成功: #{subscribe_params[:email]}"
2016-04-26 00:20:14 +08:00
redirect_to unsubscribes_path
end
2016-04-27 16:12:56 +08:00
def subscribe_params
params.require(:subscribe).permit(:email)
end
2016-04-26 00:20:14 +08:00
end