-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #237 from TreinaDev/feat/adiciona-friendlyid-a-out…
…ros-models Feat/adiciona friendlyid a outros models
- Loading branch information
Showing
11 changed files
with
37 additions
and
9 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,21 @@ | ||
class CommentsController < ApplicationController | ||
before_action :authenticate_user! | ||
before_action :set_post | ||
|
||
def create | ||
post = Post.find(params[:post_id]) | ||
comments_params = params.require(:comment).permit(:message) | ||
comments_params[:user_id] = current_user.id | ||
comment = post.comments.build(comments_params) | ||
comment = @post.comments.build(comments_params) | ||
if comment.save | ||
redirect_to post, notice: t('.success') | ||
redirect_to @post, notice: t('.success') | ||
else | ||
redirect_to post, alert: t('.error') | ||
redirect_to @post, alert: t('.error') | ||
end | ||
end | ||
end | ||
|
||
private | ||
|
||
def set_post | ||
@post = Post.friendly.find(params[:post_id]) | ||
end |
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class AddSlugToPosts < ActiveRecord::Migration[7.1] | ||
def change | ||
add_column :posts, :slug, :string | ||
add_index :posts, :slug, unique: true | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class AddSlugToInvitations < ActiveRecord::Migration[7.1] | ||
def change | ||
add_column :invitations, :slug, :string | ||
add_index :invitations, :slug, unique: true | ||
end | ||
end |
File renamed without changes.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.