こんにちは、アプリケーションで簡単な検索を作成しようとしています
カレンダー.rb
def self.search(search_condition)
search_condition = "%" + search + "%"
find( :all, :conditions => ['city like ?', search_condition])
end
calendar_controller.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