ruby on rails - Routing Error uninitialized constant ArticleController -
i new ruby on rails.i written code in app/controllers/articles_controler.rb
def create @article = article.new(article_params) @article.save redirect_to @article end private def article_params params.require(:article).permit(:title, :text) end
when opened rails server got error routing error uninitialized constant articlecontroller.
in config/routes.rb have following code
rails.application.routes.draw 'articles/new' resources :article root 'welcome#index' end
controller names plural
class articlescontroller < applicationcontroller #notice, articles
this means, in config/routs.rb
, need have route maps articles
(plural).
this surely means, in config/routes.rb
, have resources :article
. , route being mapped controller named article
, don't have it, , incorrect anyway. why getting routing error uninitialized constant articlecontroller
because can't find controller named article
(singular)
it should resources :articles
. way, going controller name articles
bottom line: controller names pluralized. check namings.
Comments
Post a Comment