We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The post comment resource should fulfill requirements below
The post resource should fulfill requirements below
Either you generate overload with gen.json or you generate less by gen.model, you choose.
gen.json
gen.model
mix phoenix.gen.json PostComment post_comments body:text post_id:references:posts or mix phoenix.gen.model PostComment post_comments body:text post_id:references:posts
Then associate Post-model to PostComment-model and change :on_delete to :delete_all in our migration.
Post
PostComment
:on_delete
:delete_all
web/models/post.ex
... schema "posts" do field :title, :string field :body, :string has_many :comments, Nexpo.PostComment end ...
priv/repo/migrations/[TIMESTAMP]_create_post_comment.ex
... create table(:post_comments) do add :body, :text add :post_id, references(:posts, on_delete: :delete_all) ...
Then migrate
Remember to update your repository by running migrations:
$ mix ecto.migrate
Then add route
Add the resource to your api scope in web/router.ex:
... resources "/posts", PostController do resources "/comments", PostCommentController, only: [:show, :create] end ...
Help can be found here
The text was updated successfully, but these errors were encountered:
VictorWinberg
antongoransson
easklund
martinjohansson93
saammirghorbani
ViktorClaesson
No branches or pull requests
[API] Post Comments
The post comment resource should fulfill requirements below
The post resource should fulfill requirements below
Generate a json post comment resource with body
Either you generate overload with
gen.json
or you generate less bygen.model
, you choose.Spoiler
Then associate
Post
-model toPostComment
-model and change:on_delete
to:delete_all
in our migration.Spoiler
web/models/post.ex
priv/repo/migrations/[TIMESTAMP]_create_post_comment.ex
Then migrate
Spoiler
Remember to update your repository by running migrations:
Then add route
Spoiler
Add the resource to your api scope in web/router.ex:
Edit your json
Post
andPostComment
resource so it fulfills requirements.Help can be found here
The text was updated successfully, but these errors were encountered: