我已經包括是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):
請指導我如何解決這個問題。
哪裏是在你的應用程序你是inflections.rb文件? – rick
請將'leaves/new'模板代碼粘貼 –
config/initializers/inflections.rb – railslearner