Skip to content

Instantly share code, notes, and snippets.

@zarkomilosevic
Last active August 30, 2017 21:29
Show Gist options
  • Save zarkomilosevic/bf42eb1631a8947f6b0df9086c7f9410 to your computer and use it in GitHub Desktop.
Save zarkomilosevic/bf42eb1631a8947f6b0df9086c7f9410 to your computer and use it in GitHub Desktop.
def get_all
@todos = Todo.all
render json: @todos
end
def create
@todo = Todo.create(todo_params)
respond_to do |format|
format.json do
if @todo.save
render :json => @todo
else
render :json => { :errors => @todo.errors.messages }, :status => 422
end
end
end
end