ruby on rails - The dreaded missing template error -


i've read can find, , i'm still stumped.

i'm trying use before_filter catch users not logged in, , send them alternative index page. idea users logged in see listing of own articles when hit index.html.erb, users not logged in redirect showall.html.erb page lists articles not let them read them (and hits them ads).

i added route:

resources :articles do
"showall"
resources :comments
end

'rake routes' shows route article_showall. have partial _showall.html.erb in views/articles folder (it contains text 'showall working!'). if render showall in view (<%= render "showall" %>), works fine.

this applicable part of controller:

class articlescontroller < applicationcontroller skip_before_action :authorize, only: [:index, :show, :showall] before_filter :require_user, :only => [:index]  def require_user unless user.find_by(id: session[:user_id])   render 'showall', :notice => "please log in read articles." end end  def index  @articles = current_user.articles  end  def showall @articles = article.all end 

when run (while not logged in), following error:

missing template articles/showall, application/showall with....etc 

i'm stumped. why can render 'showall' in view, missing template error when refer in controller? thank in advance help!

david , user4703663 right. problem named template partial rendering template. either remove underscore file name , leave code is, or leave filename , "render partial: 'showall'" index view.

edit: should add missing template error should not instill dread in heart. it's guiding mistake, directly. don't stress , try remember meant next time. it's typo, or loading partial naming template or vice versa, or forgetting subfolder relative path or that. it's normal, , interpreter spits errors you, not oppress you. 😄


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -