Nothing happens when submitting the form

Viewed 29
<div id="main-create-task"
<div>

 <div id="newtask-form>"
 <%= form_with model: [@categories,@categories.tasks.build] do |form| %>
 <% if task.errors.any? %>
 <div id="error_explanation">
  <h2><%= pluralize(task.errors.count, "error") %> prohibited this task from being saved:</h2>

  <ul>
  <% task.errors.each do |error| %>
         <li><%= error.full_message %></li>
  <% end %>
  </ul>

  <% end %>
 </div>

 <div id="create-task">
  <div>
 <h1>New Task</h1>
 </div>

 <div>
  <%= form.label :Task_name %>
  <%= form.text_field :taskname%>
 </div>
  <br>

 <div>
  <%= form.label :Description %>
  <%= form.text_area :taskbody%>
 </div>
  <br>

 <div>
  <%= form.label :Time %>
  <%= form.text_field :tasktime%>
 </div>
  <br>

  
  <%=form.submit "Submit" %>
  </div>
 </div>
 <% end %>
 </div>
 </div>
 </div>

This is my task controller .

def new
@categories = current_user.categories.find(params[:category_id])
@task = Task.new
end


 def edit
 @categories = Category.find(params[:category_id])
 @task = Task.find(params[:id])
 end


 def create
  @category = current_user.categories.find(params[:category_id])
  @task = @category.tasks.build(task_params)
  @task.user_id = current_user.id

  if @task.save
    redirect_to categories_path
  else
    redirect_to category_path
  end

I run this code and it does not give me any error . When i click submit , nothing happens . no error its just really nothing happen .

I see about its being handle by javascript . I didn't touch anything in Javascript and we dont use javascript for now . Need assistance , presentation will be later

1 Answers

Ruby on Rails comes with JS. By default form_with attaches the data-remote attribute submitting the form via an XMLHTTPRequest in the background if an Unobtrusive JavaScript driver, like rails-ujs, is used. Source.

To disable remote submits use local: true:

<%= form_with model: [@categories,@categories.tasks.build], local: true do |form| %>
Related