Last active
August 30, 2017 21:29
-
-
Save zarkomilosevic/bf42eb1631a8947f6b0df9086c7f9410 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/rubydonkey/flux-todomvc-rails-51/blob/35af561f3ea8560c63c685aa416cc65538fdfbfd/app/controllers/todos_controller.rb#L11