ruby on rails - undefined method `edit_class_timetable_path' for #<#<Class:0x0...> -
generated timetable scaffold. later added new action "clas" timetables_controller.rb.
timetables_controller.rb
class timetablescontroller < applicationcontroller   before_action :set_timetable, only: [:show, :edit, :update, :destroy]   respond_to :html  def clas   @classtimetable = timetable.all end  private def set_timetable   @timetable = timetable.find(params[:id]) end  def timetable_params   params.require(:timetable).permit(:day, :clas) end  end and view consists of
clas.html.erb
<% @classtimetable.each |class_timetable| %>   <%= class_timetable.day %>   <%= class_timetable.clas %>   <%= link_to 'edit', edit_class_timetable_path(class_timetable) %> <% end %> getting error couldn't find timetable without id , error highlighted at,
@timetable = timetable.find(params[:id])
and routes.rb consists of
resources :timetables collection   'clas' end end got answer
i made mistake on here
<%= link_to 'edit', edit_class_timetable_path(class_timetable) %> to
<%= link_to 'edit', "/timetables/#{class_timetable.id}/edit" %> or
<%= link_to 'edit', clas_timetables_path(id: class_timetable.id) %>  
 
Comments
Post a Comment