ruby on rails - Undefined method "cmdb_searches_path" for form_for in index -
i have cmdbs_controller.rb inside of have index , defined cmdb resource route:
def index @cisearch = cmdbsearch.new end
also have cmdb_search model model search form (empty). in index.html.erb want load form_for that:
<%= form_for @cisearch, remote:true |f| %> ...some code.. <% end %>
i have done such search other page before, error:
undefined method `cmdb_searches_path'
edit: there no cmdb_search controller, cmdb_model created building search form, used temorarily. example worked: did before , worked:
#requests_controller.rb def index if !user_signed_in? redirect_to new_user_session_path else @requests = request.search(params[:search]).order("#{sort_column} #{sort_direction}").where("payed = ?", false).order(created_at: :desc).paginate(per_page: 20, page: params[:page]) @search = search.new end end
<%= form_for @search, remote: true |f| %> .. code <% end %>
the way works create search model instance inside requests_controller able create form_for @search. didn't define specific routes, resource ones. worked before 1 isn't working.
since rendering form index action, not knows create action. modify form_for as:
form_for @cisearch, :url => your_create_action,remote:true
Comments
Post a Comment