當嘗試使用simple_form,我遇到了以下錯誤解決未定義的方法`TO_KEY」錯誤: 如何使用simple_form
undefined method `to_key' for #<CourseQuery::ActiveRecord_Relation:0x007f070689bae8>
這是相關負責人:
class Students::DashboardController < ApplicationController
before_filter :authenticate_student!
def index
@course_query=CourseQuery.all
end
def show
end
def course_queries_details
@course_queries = current_student.course_queries
@course_query = CourseQuery.new
end
end
The view,views/students/dashboard/course_queries_details.html.erb:
<%= simple_form_for (@course_query) do |m| %>
<div class="modal-body">
<%= m.input :message ,label: false %>
</div>
<% end %>
的config/routes.rb文件:
namespace :students do
root to: "dashboard#show"
get 'course-queries-details', to: 'dashboard#course_queries_details'
resources :students
end
誰能告訴我如何解決這個問題?
@穆罕默德謝謝。我已經通過相同的方式解決了它 – SreRoR