No route matches [POST] "/artworks/2/edit"
Rails.root: c:/Users/bburns/Desktop/arttour
Application Trace | Framework Trace | Full Trace
Routes
Routes match in priority from top to bottom
Helper HTTP Verb Path Controller#Action
Path / Url
welcome_index_path GET /welcome/index(.:format) welcome#index
artworks_path GET /artworks(.:format) artworks#index
POST /artworks(.:format) artworks#create
new_artwork_path GET /artworks/new(.:format) artworks#new
edit_artwork_path GET /artworks/:id/edit(.:format) artworks#edit
artwork_path GET /artworks/:id(.:format) artworks#show
PATCH /artworks/:id(.:format) artworks#update
PUT /artworks/:id(.:format) artworks#update
DELETE /artworks/:id(.:format) artworks#destroy
root_path GET / welcome#index
Request
Parameters:
{"utf8"=>"?",
"authenticity_token"=>"0+8G5XLT4b6/3U1v6K4p0GnpcSxjsti8wid/+akAlDrFEQEfeVvnwp9Jte+ohyJGFUIw0vqYGnPcQxAP4rEijA==",
"artwork"=>{"artist"=>"inness",
"year"=>"1889",
"title"=>"moonrise",
"about"=>""},
"commit"=>"Save Artwork"}
Rails.application.routes.draw do
get 'welcome/index'
resources :artworks
root 'welcome#index'
end
class ArtworksController < ApplicationController
def index
@artworks = Artwork.all
end
def show
@artwork = Artwork.find(params[:id])
end
def new
@artwork = Artwork.new
end
def edit
@artwork = Artwork.find(params[:id])
end
def create
@artwork = Artwork.new(artwork_params)
if @artwork.save
redirect_to @artwork
else
render 'new'
end
end
def update
@artwork = Artwork.find(params[:id])
if @artwork.update(artwork_params)
redirect_to @artwork
else
render 'edit'
end
end
private
def artwork_params
params.require(:artwork).permit(:artist, :title, :year, :about)
end
end
<h1>Editing artwork</h1>_form.html.erb:
<%= render 'form' %>
<%= link_to 'Back', artworks_path %>
<%= form_for :artwork do |f| %>
<% if @artwork.errors.any? %>
<div id="error_explanation">
<h2>
<%= pluralize(@artwork.errors.count, "error") %> prohibited
this artwork from being saved:
</h2>
<ul>
<% @artwork.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<p>
<%= f.label :artist %><br>
<%= f.text_field :artist %>
</p>
<p>
<%= f.label :year %><br>
<%= f.text_field :year %>
</p>
<p>
<%= f.label :title %><br>
<%= f.text_field :title %>
</p>
<p>
<%= f.label :about %><br>
<%= f.text_area :about %>
</p>
<p>
<%= f.submit %>
</p>
<% end %>
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Documentation" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-do...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-docs.
For more options, visit https://groups.google.com/d/optout.