1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rails: posts_pathについて

Last updated at Posted at 2015-11-22

Post_pathとは以下の場合、#indexの事。
つまり下のケースだと、posts/indexにリダイレクトするように指定している。
間違ってたらごめんなさい。

まだちょっと混乱中、これどういう仕組みでindexを指定してるんだろ?

route.rb

posts GET /posts(.:format) posts#index
posts_new GET /posts/new(.:format) posts#new
GET /posts/:id(.:format) posts#show
POST /posts(.:format) posts#create


def create
@post = Post.new(
title: params[:post][:title],
author: params[:post][:author].
text: params[:post][:text]
)
if @post.save
refirect_to posts_path
else
render :new
end
end

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?