Skip to content

Instantly share code, notes, and snippets.

@mkhairi
Last active October 10, 2016 02:51
Show Gist options
  • Save mkhairi/eee1bf67f4dbb51acc65db74ead87af9 to your computer and use it in GitHub Desktop.
Save mkhairi/eee1bf67f4dbb51acc65db74ead87af9 to your computer and use it in GitHub Desktop.

Revisions

  1. mkhairi revised this gist Oct 10, 2016. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions rails 5 note
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ```
    #respond remote true redirect
    def create
    @post = Post.new(post_params)
    respond_to do |format|
    @@ -12,4 +12,3 @@
    end
    end
    end
    ```
  2. mkhairi revised this gist Oct 10, 2016. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions rails 5 note
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    def create
    ```
    def create
    @post = Post.new(post_params)
    respond_to do |format|
    if @post.save
    @@ -10,4 +11,5 @@
    format.json { render json: @post.errors, status: :unprocessable_entity }
    end
    end
    end
    end
    ```
  3. mkhairi created this gist Oct 10, 2016.
    13 changes: 13 additions & 0 deletions rails 5 note
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    def create
    @post = Post.new(post_params)
    respond_to do |format|
    if @post.save
    format.js { redirect_to post_comments_path(@post), turbolinks: false}
    #or
    #redirect_to post_comments_path(@post), status: 303, turbolinks: false
    else
    format.html { render :new }
    format.json { render json: @post.errors, status: :unprocessable_entity }
    end
    end
    end