Simplification of the 'link_back' code
This commit is contained in:
1 parent
d88cae437d
commit
1909edbe2a
13 files changed
+23
-44
No files matched your search
@@ -11,28 +11,6 @@ class ApplicationController < ActionController::Base
|
||||
@parent_item = Item.first(:conditions => { :id => BSON::ObjectId(params[:parent_id]) }) rescue nil
|
||||
end
|
||||
|
||||
|
||||
# Clean the link back
|
||||
# Remove the locale but keep all the other params
|
||||
def get_go_back
|
||||
begin
|
||||
if env['REQUEST_URI'].include?('locale=')
|
||||
session[:last_page]
|
||||
else
|
||||
target = env['HTTP_REFERER'].split('?')
|
||||
vars = target[1].split('&')
|
||||
vars.delete_if {|var| var.include? 'locale=' }
|
||||
if vars.size > 0
|
||||
target[0].to_s + '?' + vars.join('&')
|
||||
else
|
||||
target[0].to_s
|
||||
end
|
||||
end
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
# Check if the current_user is admin
|
||||
def is_admin?
|
||||
redirect_to root_url unless current_user.admin?
|
||||
|
||||
Reference in new issue
Block a user