Module: Divert

Defined in:
lib/divert.rb,
lib/divert/engine.rb,
lib/divert/version.rb,
app/models/divert/redirect.rb

Defined Under Namespace

Classes: Engine, Redirect

Constant Summary collapse

VERSION =
"0.6"

Instance Method Summary collapse

Instance Method Details

#action_missing(path = nil) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/divert.rb', line 4

def action_missing path = nil
  path ||= params[:path]
  if action_methods.include? path
    send path and return
  end

  if template_exists?(path, [controller_name])
    render "#{controller_name}/#{path}" and return
  end

  if (redirect = Redirect.hit request.fullpath)
    redirect_to redirect
  else
    unless template_exists? 'divert', [controller_name]
      render text:"Missing divert view: #{controller_name}/divert.html.erb", :status => 404 and return
    end
    render "#{controller_name}/divert", :status => 404 and return
  end
end