Set flash in application controller

This commit is contained in:
Erik Michaels-Ober 2011-08-29 17:50:51 -07:00
parent 8e9f963a68
commit 8de04a6cab
2 changed files with 11 additions and 5 deletions

View File

@ -1,3 +1,14 @@
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
protect_from_forgery protect_from_forgery
before_filter :set_flash_from_params
protected
def set_flash_from_params
if params[:flash]
params[:flash].each do |key, message|
flash.now[key.to_sym] = message
end
end
end
end end

View File

@ -1,11 +1,6 @@
class InfoWindowController < ApplicationController class InfoWindowController < ApplicationController
def index def index
@hydrant = Hydrant.find_by_id(params[:hydrant_id]) @hydrant = Hydrant.find_by_id(params[:hydrant_id])
if params[:flash]
params[:flash].each do |key, message|
flash.now[key.to_sym] = message
end
end
if @hydrant.adopted? if @hydrant.adopted?
if user_signed_in? && current_user.id == @hydrant.user_id if user_signed_in? && current_user.id == @hydrant.user_id
render("users/thank_you") render("users/thank_you")