1
我試圖創建一個感謝您網頁,我的這條路線,因爲我測試的URL和工作得很好工作正常,但是當我嘗試在創建操作重定向我得到:路由錯誤在行動顯示,如何解決它?
沒有路由匹配{:行動=> 「節目」,:控制器=> 「日程表」,:區域設置=>:EN,:ID =>零}
控制器
def create
@appointment = Appointment.new(params[:appointment])
if @appointment.save
#send email
AppointmentMailer.appointment_confirmation(@appointment).deliver
AppointmentMailer.new_appointment(@appointment).deliver
redirect_to :action => "thank_you"
else
render :action => 'new', :alert => @appointment.errors.full_messages.split(', ')
end
end
def new
@schedule = Schedule.find(params[:id])
@appointment = @schedule.appointments.new
end
def thank_you
@appointment = Appointment.find(params[:id])
end
路線
scope ":locale", :locale => /#{I18n.available_locales.join("|")}/ do
root :to => "Doctors#index"
resources :specialties
resources :branches
resources :doctors do
get 'new_schedule', :on => :member, :controller => 'schedules', :action => 'new'
end
# NIA: Here is the trick: we remove /shedules/new route (with :except => :new)
# and map /doctors/new_schedule instead to SchedulesController#new action (see above)
# (the same is done with appointments)
resources :schedules, :except => :new do
get 'new_appointment', :on => :member, :controller => 'appointments', :action => 'new'
end
resources :appointments do
member do
get :thank_you
end
end
end
match '*path', :to => redirect("/#{I18n.default_locale}/%{path}")
match '', :to => redirect("/#{I18n.default_locale}")
約會控制器似乎沒有關係。你試圖鏈接到哪裏,或者使用'scheduleles#show'? –