当我尝试访问新的操作时,为什么会发生这种情况?

routes.rb
resources :tvseriestvseries_controller.rb
class TvseriesController < ApplicationController
before_action :set_tvseries, only: [:show, :edit, :update, :destroy]
# GET /tvseries
# GET /tvseries.json
def index
@tvseries = Tvserie.all
end
# GET /tvseries/1
# GET /tvseries/1.json
def show
end
# GET /tvseries/new
def new
@tvseries = Tvserie.new
end
# GET /tvseries/1/edit
def edit
end
# POST /tvseries
# POST /tvseries.json
def create
@tvseries = Tvserie.new(tvseries_params)
respond_to do |format|
if @tvseries.save
format.html { redirect_to @tvseries, notice: 'Tvserie was successfully created.' }
format.json { render :show, status: :created, location: @tvseries }
else
format.html { render :new }
format.json { render json: @tvseries.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /tvseries/1
# PATCH/PUT /tvseries/1.json
def update
respond_to do |format|
if @tvseries.update(tvseries_params)
format.html { redirect_to @tvseries, notice: 'Tvserie was successfully updated.' }
format.json { render :show, status: :ok, location: @tvseries }
else
format.html { render :edit }
format.json { render json: @tvseries.errors, status: :unprocessable_entity }
end
end
end
# DELETE /tvseries/1
# DELETE /tvseries/1.json
def destroy
@tvseries.destroy
respond_to do |format|
format.html { redirect_to tvseries_url, notice: 'Tvserie was successfully destroyed.' }
format.json { head :no_content }
end
end
# GET /all_tv_series
def all
@tv_series = Tvserie.all
end
# GET /tv_series/add_language/1
# GET /tv_s/add_language/1.json
def add_subtitles
@languages = Language.all
end
private
# Use callbacks to share common setup or constraints between actions.
def set_tvseries
@tvseries = Tvserie.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def tvseries_params
params.require(:tvseries).permit(:title, :image, :description)
end
end_form.html.erb
<%= form_for(@tvseries) do |f| %>
<% if @tvseries.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@tvseries.errors.count, "error") %> prohibited this tvseries from being saved:</h2>
<ul>
<% @tvseries.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :title %><br>
<%= f.text_field :title %>
</div>
<div class="field">
<%= f.label :image %><br>
<%= f.text_field :image %>
</div>
<div class="field">
<%= f.label :description %><br>
<%= f.text_area :description %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>rake路由
tvseries_index GET /tvseries(.:format) tvseries#index
POST /tvseries(.:format) tvseries#create
new_tvseries GET /tvseries/new(.:format) tvseries#new
edit_tvseries GET /tvseries/:id/edit(.:format) tvseries#edit
tvseries GET /tvseries/:id(.:format) tvseries#show
PATCH /tvseries/:id(.:format) tvseries#update
PUT /tvseries/:id(.:format) tvseries#update
DELETE /tvseries/:id(.:format) tvseries#destroy模式
create_table "tvseries", force: :cascade do |t|
t.string "title"
t.text "description"
t.string "image"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end发布于 2016-03-25 20:20:32
问题在于命名约定。
be级数既可用于单数形式,也可用于复数形式。
您应该将模型名更改为Tvseries而不是Tvserie
https://stackoverflow.com/questions/36226961
复制相似问题