Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def store_location location=nil
- session[:return_to] = location || request.request_uri
- end
- def redirect_back_or_default(default)
- redirect_to(session[:return_to] || default)
- session[:return_to] = nil
- end
- def http_referrer
- http_referer, request_path = request.env["HTTP_REFERER"],
- request.env["REQUEST_PATH"]
- return nil unless (http_referer and request_path and
- http_referer =~ Regexp.new("^#{SITE_ROOT}") and
- http_referer != (SITE_ROOT + request_path))
- return http_referer
- end
- before_filter :store_location, :only => [:new, :edit]
- def store_location
- super http_referrer
- end
- def create
- if @user.save
- flash[:notice] = "Successfully created the user."
- redirect_back_or_default root_url
- else
- render :action => 'new'
- end
- end
- def update
- if @user.save
- flash[:notice] = "Successfully created the user."
- redirect_back_or_default root_url
- else
- render :action => 'new'
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement