当我转到我的页面127.0.0.1/searches/new
并单击提交时,我得到:
ActionView::MissingTemplate in Searches#show
Missing partial searches/search with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}. Searched in:
我不明白为什么,因为通常 Rails 将结果发送到yield
,不是吗?
在我的show.html
:
<%= render @search.calendars %>
在我的控制器中searches_controller.rb
:
def new
@search = Search.new
end
def create
@search = Search.create!(params[:params])
redirect_to @search
end
def show
@search= Search.find(params[:id])
end
在我的模型中searches.rb
:
def calendars
@calendars ||= find_calendars
end
private
def find_calendars
calendars = Calendar.order(:event)
calendars = calendars.where("event like ?", "%#{keywords}%") if keywords.present?
calendars
end
在我的routes.rb
:
resources :searches