I have a problem with my app, I will now give you the code to from the app and picture of the error, this is my task: I am supposed to create a web app from ruby on rails and the app should create articles and save them to the database.
This is the image of the error: http://ift.tt/2wGEEzJ
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'
article.rb:
class Article < ActiveRecord::Base
end
articles_controller.rb:
class ArticlesController < ApplicationController
def new
@article = Article.new
end
def create
#render plain: params[:article].inspect
@article.save
redirect_to_articles_show(@article)
end
private
def article_params
params.require(:article).permit(:title, :description)
end
end
new.html.erb:
Create an article
<%= form_for @article do |f| %>
<p>
<%= f.label :title %>
<%= f.text_field:title %>
</p>
<p>
<%= f.label :description %>
<%= f.text_area :description %>
</p>
<p>
<%= f.submit %>
</p>
<% end %>
my migration file:
class CreateArticles < ActiveRecord::Migration
def change
create_table :articles do |t|
t.string :title
t.text :description
end
end
end
my schema.rb:
ActiveRecord::Schema.define(version: 20170820190312) do
create_table "articles", force: :cascade do |t|
t.string "title"
t.text "description"
end
end
Aucun commentaire:
Enregistrer un commentaire