Advertisement
ChinaToster

Untitled

Jul 6th, 2019
2,537
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 0.46 KB | None | 0 0
  1. class TodosController < ApplicationController
  2.   def index
  3.     @todos = Todo.all
  4.   end
  5.  
  6.   def update
  7.  
  8.   end
  9.  
  10.   def new
  11.     @todo = Todo.new
  12.   end
  13.  
  14. def create
  15.     @todo = Todo.new (todo_params)
  16.     @todo.project_id = params[:todo_params]
  17.       if @todo.save
  18.         redirect_to root_path
  19.       else
  20.         render root_path
  21.       end
  22.     end
  23.  
  24.  
  25.   private def todo_params
  26.     params.require(:todo).permit(:text, :isCompleted, :project_id)
  27.  
  28.   end
  29. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement