我在任何地方都看到过这个问题,但它永远不能解决我的问题。继承人我的控制器:无法为UserVacationDaysController找到'创建'动作
class UserVacationDaysController < ApplicationController
def new
@user = current_user
@user_vacation_days = UserVacationDay.new
end
def create
@user_vacation_days = UserVacationDay.create(params[:user_vacation_day])
@user_vacation_days.user = current_user
# @user_vacation_days.calculate_work_days
# (another param that holds date range will get passed in)
# puts @user_vacation_days.errors.inspect
if @user_vacation_days.persisted?
flash[:notice] = "Request Sent"
redirect_to dashboard_index_path
request_vacation_days # method from model. model method calls method in employee_mailer
else
flash[:notice] = "Something went wrong, please try again"
render :new
end
end
end
这里是我的看法(表单)。
<h2>Request Days Off</h2>
<%= form_for :user_vacation_days, :url => user_vacation_days_path do |f| %>
<div><%= f.label "How much time off would you like to take?" %>
<%= f.number_field :number_of_days %></div>
<div><%= f.label "Argue your case, slave" %>
<%= f.text_area :description %></div>
<div><%= f.submit "Request Time Off" %></div>
<% end %>
的路线我的2种控制器方法
user_vacation_days POST /user_vacation_days(.:format) user_vacation_days#create
new_user_vacation_day GET /user_vacation_days/new(.:format) user_vacation_days#new
没有人有任何想法是怎么回事?我看遍了各处,我找不到任何东西。我想不出为什么控制器方法不会被找到。谢谢!
你可以在你的form_for中添加':method =>'POST''并查看它是否清除了它? –
奇怪..你尝试重新启动你的Rails服务器吗? – Benj
我重新启动了rails服务器,它工作。谢谢本 – Mike