Skip to content

Commit

Permalink
readding json boilerplate for new/create actions
Browse files Browse the repository at this point in the history
  • Loading branch information
adamico committed Nov 12, 2013
1 parent 1f37b38 commit 4233663
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions app/controllers/notes_controller.rb
Expand Up @@ -21,23 +21,35 @@ def show
end end
end end


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


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


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


if @note.save respond_to do |format|
User.invite!({email: @note.borrower_email, name: @note.borrower_name}, current_user) if @note.save
redirect_to @note, notice: 'Note was successfully created.' User.invite!({email: @note.borrower_email, name: @note.borrower_name}, current_user)
else format.html { redirect_to @note, notice: 'Note was successfully created.' }
render action: "new" 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
end end


Expand Down

6 comments on commit 4233663

@akshatpradhan
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@adamico
Copy link
Owner Author

@adamico adamico commented on 4233663 Nov 12, 2013 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akshatpradhan
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@adamico
Copy link
Owner Author

@adamico adamico commented on 4233663 Nov 12, 2013 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamico
Copy link
Owner Author

@adamico adamico commented on 4233663 Nov 12, 2013 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akshatpradhan
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je ne sais pas :octocat:

Please sign in to comment.