Skip to content
Permalink
Browse files

readding json boilerplate for new/create actions

  • Loading branch information
adamico committed Nov 12, 2013
1 parent 1f37b38 commit 42336633fbcad428fd6b54be60cd47bcd56de4aa
Showing with 17 additions and 5 deletions.
  1. +17 −5 app/controllers/notes_controller.rb
@@ -21,23 +21,35 @@ def show
end
end

# GET /notes/new
# GET /notes/new.json
def new
@note = Note.new(user_id: current_user.id)
respond_to do |format|
format.html # new.html.erb
format.json { render json: @note }
end
end

# GET /notes/1/edit
def edit
@note = Note.find(params[:id])
end

# POST /notes
# POST /notes.json
def create
@note = Note.new(params[:note])

if @note.save
User.invite!({email: @note.borrower_email, name: @note.borrower_name}, current_user)
redirect_to @note, notice: 'Note was successfully created.'
else
render action: "new"
respond_to do |format|
if @note.save
User.invite!({email: @note.borrower_email, name: @note.borrower_name}, current_user)
format.html { redirect_to @note, notice: 'Note was successfully created.' }
format.json { render json: @note, status: :created, location: @note }
else
format.html { render action: "new" }
format.json { render json: @note.errors, status: :unprocessable_entity }
end
end
end

6 comments on commit 4233663

@akshatpradhan

This comment has been minimized.

Copy link

akshatpradhan replied Nov 12, 2013

@adamico ok, I see this commit and it makes sense. How do I merge this?

@adamico

This comment has been minimized.

Copy link
Owner Author

adamico replied Nov 12, 2013

@akshatpradhan

This comment has been minimized.

Copy link

akshatpradhan replied Nov 12, 2013

I'm not sure I understand. How do I merge the PR again? I already clicked the Merge PR button.

@adamico

This comment has been minimized.

Copy link
Owner Author

adamico replied Nov 12, 2013

@adamico

This comment has been minimized.

Copy link
Owner Author

adamico replied Nov 12, 2013

@akshatpradhan

This comment has been minimized.

Copy link

akshatpradhan replied Nov 12, 2013

Je ne sais pas :octocat:

Please sign in to comment.
You can’t perform that action at this time.