次のエラーが表示されます
No route matches {:action=>"show", :controller=>"settings", :format=>nil}
設定/新規を実装しようとしている間。
私の settings/new.html は次のとおりです。
<h1>New setting</h1>
<%= form_for @setting do |f| %>
<% if @setting.errors.any? %>
<div id="errorExplanation">
<h2><%= pluralize(@setting.errors.count, "error") %> prohibited this setting from being saved:</h2>
<ul>
<% @setting.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
</br></br>
Id: <%= f.text_field :id %><br>
Name: <%= f.text_field :name %><br>
<%= f.submit "Create" %>
<% end %>
設定用の routes.rb ファイルは次のとおりです。
resources :settings do
member do
post 'add'
post 'remove'
get 'settings/id'
end
collection do
get 'add'
get 'list' => "settings#index"
post 'get_settings'
get 'get_settings'
end
end
resources :settings
私の設定コントローラー:
class SettingsController < ApplicationController
# GET /Settings
# GET /Settings.json
def index
@settings = Setting.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @settings }
end
end
# GET /Settings/1
# GET /Settings/1.json
def show
@setting = Setting.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @setting }
end
end
# GET /Settings/new
# GET /Settings/new.json
def new
@setting = Setting.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @setting }
end
end
# GET /Settings/1/edit
def edit
@setting = Setting.find(params[:id])
end
# POST /Settings
# POST /Settings.json
def create
@setting = Setting.new(params[:setting])
respond_to do |format|
if @Setting.save
format.html { redirect_to @setting, notice: 'Lov value was successfully created.' }
format.json { render json: @setting, status: :created, location: @setting }
else
format.html { render action: "new" }
format.json { render json: @setting.errors, status: :unprocessable_entity }
end
end
end
# PUT /Settings/1
# PUT /Settings/1.json
def update
@setting = Setting.find(params[:id])
respond_to do |format|
if @Setting.update_attributes(params[:setting])
format.html { redirect_to @setting, notice: 'Lov value was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @setting.errors, status: :unprocessable_entity }
end
end
end
# DELETE /Settings/1
# DELETE /Settings/1.json
def delete
@setting = Setting.find(params[:id])
@setting.deleted = 1
@setting.save
respond_to do |format|
format.html { redirect_to settings_url }
format.json { render :json => { :success => true } }
end
end
end
私のレーキ ルートは次のとおりです。
add_settings POST /settings/:id/add(.:format) settings#add
remove_settings POST /settings/:id/remove(.:format) settings#remove
settings_id_settings GET /settings/:id/settings_id(.:format) settings#settings_id
add_settings_index GET /settings/add(.:format) settings#add
list_settings_index GET /settings/list(.:format) settings#index
get_settings_settings_index POST /settings/get_settings(.:format) settings#get_settings
GET /settings/get_settings(.:format) settings#get_settings
GET /settings(.:format) settings#index
POST /settings(.:format) settings#create
GET /settings/new(.:format) settings#new
GET /settings/:id/edit(.:format) settings#edit
GET /settings/:id(.:format) settings#show
PUT /settings/:id(.:format) settings#update
DELETE /settings/:id(.:format) settings#destroy
GET /settings(.:format) settings#index
POST /settings(.:format) settings#create
GET /settings/new(.:format) settings#new
GET /settings/:id/edit(.:format) settings#edit
GET /settings/:id(.:format) settings#show
PUT /settings/:id(.:format) settings#update
DELETE /settings/:id(.:format) settings#destroy
確認してお知らせください。