I am trying to conditionally route two different controller actions. I have created RoutesController#root
and sent root
there from routes.rb, however the app just wants to find a root template to render no matter what i write in the root method.
What I am trying to achieve is:
- user requests ‘/’
- user gets pushed to sign in
- upon successful sign in if
current_user.company.present?
(current_user should be available in the Routes controller right?) then render Quotes#new - else if no company then render Companies#new
I'm hitting a missing template error;
Missing template companies/1/quotes/new.1 with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :coffee, :jbuilder]}. Searched in: * "app/views"
I want it to be searching in app/views/quotes/new, what am i doing wrong?
RoutesController.rb
class RoutesController < ActionController::Base
before_filter :authenticate_user!
def root
if current_user.company.present?
render new_company_quote_path(current_user)# 'quotes#new'
else
render new_company_path(current_user) # 'companies#new'
end
end
end
routes.rb
root 'routes#root'