0
我用腳手架創建了一個應用程序,用戶可以在其中創建字母(新手)。路由錯誤未初始化的常量 - 如何編輯腳手架路由?
當檢討信創造增加一個額外的視圖(「應用程序/視圖/字母/ review.html.erb」)我遇到路由問題嘗試通過我認爲的路徑重定向
redirect_to review_path, notice: 'Letter was successfully created.'
現在應該工作:
match '/review', to: 'letter#review', via: 'get'
我做錯了什麼?
全部成立,控制器:
class LettersController < ApplicationController
before_action :set_letter, only: [:show, :edit, :update, :destroy, :review]
def review
end
...
def create
@letter = Letter.new(letter_params)
@letter.user_id = current_user.id if current_user
respond_to do |format|
if @letter.save
format.html { redirect_to review_path, notice: 'Letter was successfully created.' }
format.json { render action: 'show', status: :created, location: dashboard_path }
else
format.html { render action: 'new' }
format.json { render json: @letter.errors, status: :unprocessable_entity }
end
end
end
路線:
Appname::Application.routes.draw do
resources :letters
resources :charges
devise_for :users
get 'letter/new'
root 'static_pages#home'
match '/review', to: 'letter#review', via: 'get'
match '/dashboard', to: 'account#dashboard', via: 'get'
match '/order', to: 'account#order', via: 'get'
Lifesaver,感謝您的闡述。 –
很高興幫助:) –