1

この質問がどこでも聞かれるのを見てきましたが、私の問題は決して解決しません。ここに私のコントローラーがあります:

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

何が起こっているのか誰にも分かりませんか?私はあちこちを見回しましたが、何も見つかりません。コントローラーメソッドが見つからない理由は考えられません。ありがとう!

4

1 に答える 1