Ruby on rails 3 行动秀中的路由错误,如何修复?
我正在尝试创建一个感谢页面,我的路线运行良好,因为我测试了它的url,运行良好,但是当我尝试在创建操作中重定向时,我得到: 没有路由匹配{:action=>“show”,:controller=>“schedules”,:locale=>:en,:id=>nil} 控制器Ruby on rails 3 行动秀中的路由错误,如何修复?,ruby-on-rails-3,Ruby On Rails 3,我正在尝试创建一个感谢页面,我的路线运行良好,因为我测试了它的url,运行良好,但是当我尝试在创建操作中重定向时,我得到: 没有路由匹配{:action=>“show”,:controller=>“schedules”,:locale=>:en,:id=>nil} 控制器 def create @appointment = Appointment.new(params[:appointment]) if @appointment.save #send e
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}")
你的路线错了。您想要此(s/成员/集合): 使用“会员”,您的感谢路线将收到您未通过的id。因此它失败了。但这不会发生
在进行此更改之前,请运行“rake routes”,看看我在说什么。。。然后再运行它。您的路线错误。您想要此(s/成员/集合): 使用“会员”,您的感谢路线将收到您未通过的id。因此它失败了。但这不会发生
在进行此更改之前,请运行“rake routes”,看看我在说什么。。。然后再运行它。约会控制器似乎不相关。您尝试链接到或使用
日程#show
的位置?约会控制器似乎没有关联。您试图在哪里链接或使用计划#show
?
resources :appointments do
collection do
get :thank_you
end
end