I am having a problem while creating articles from the UI.
My task is to make a new page with "create an article" shown on the page and text fields with title and description and submit button when I press the submit button the article I typed in should be saved and when I go to the page where the articles are saved they should be there.
Error log:
This is my Cloud 9 code
routes.rb
:
Rails.application.routes.draw do
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
# root 'welcome#index'
resources :articles
root 'pages#home'
get 'about', to: 'pages#about'
Articles controller (articles_controller.rb
):
class ArticlesController < ApplicationController
def new
@article = Article.new
end
end
new.html.erb
in articles folder in views:
<h1>Create an article</h1>
<%= form_for @article do |f| %>
<% end %>
Article model (article.rb
) :
class Article
end
Is your Article
model a subclass of ActiveRecord::Base
(ApplicationRecord
from Rails 5.x)?
class Article < ActiveRecord::Base
end