Module: RailsSourcePath

Extended by:
ActiveSupport::Concern
Defined in:
lib/rails_source_path/version.rb,
lib/rails_source_path/rails_source_path.rb

Constant Summary collapse

VERSION =
"1.0.2"

Instance Method Summary collapse

Instance Method Details

#rails_source_path(default_path = root_path) ⇒ Object

rails_source_path is used in View like ‘cancel/back’ button



17
18
19
# File 'lib/rails_source_path/rails_source_path.rb', line 17

def rails_source_path(default_path = root_path)
  session[:rails_source_path] || default_path
end

#redirect_to_source(default_path = root_path) ⇒ Object

used in controller when object is successfully created or updated



22
23
24
25
26
# File 'lib/rails_source_path/rails_source_path.rb', line 22

def redirect_to_source(default_path = root_path)
  path = rails_source_path(default_path)
  session.delete(:rails_source_path)
  redirect_to path
end