我已经包含了 inflections.rb
ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.irregular 'leaves', 'leaves'
end
和我的控制器 Leaves_controller.rb
class LeavesController < ApplicationController
def new
@leave = Leave.new
end
def create
@leave = Leave.create(leave_params)
if @leave.errors.present?
render :action => :new
else
redirect_to root_path, notice: I18n.t('leave_applied')
end
end
private
def leave_params
params.require(:leave).permit(:start_date,:end_date)
end
end
在叶子/new.html.erb
<%= form_for @leave do |f| %>
<%= f.text_field :start_date, :placeholder => 'From Date',
:class => 'datepicker' %>
<%= f.text_field :end_date, :placeholder => 'To Date',
:class => 'datepicker' %>
<%= f.submit%>
<% end %>
所以当我去叶子/新路径时,它给了我这个错误:
NameError (uninitialized constant Leaves):
请指导我如何解决这个问题。