hy 我尝试在我的应用程序上创建一个简单的搜索
日历.rb
def self.search(search_condition)
search_condition = "%" + search + "%"
find( :all, :conditions => ['city like ?', search_condition])
end
日历控制器.rb
def index
@search = @user.calendar.search(params[:search_condition])
@content_calendars = @user.calendar.all
@content_calendars_by_dates = @content_calendars.group_by(&:published_on)
@date = params[:date] ? Date.parse(params[:date]) : Date.today
end
部分_search.html.erb
<%= form_tag root_path, :method => 'get' do %>
<%= text_field_tag :search, params[:search_condition], :id => 'search_field' %>
<%= submit_tag "Search", :name => nil %>
<% end %
当我尝试时,我收到此错误:
The request method POST is inappropriate for the URL /.
我不明白为什么?
耙路线
user_calendars GET /users/:user_id/calendars(.:format) calendars#index
POST /users/:user_id/calendars(.:format) calendars#create
new_user_calendar GET /users/:user_id/calendars/new(.:format) calendars#new
edit_user_calendar GET /users/:user_id/calendars/:id/edit(.:format) calendars#edit
user_calendar GET /users/:user_id/calendars/:id(.:format) calendars#show