When i use scaffold in rails , controller creates various methods like
new,create,show,index etc
but here i can't understand transition of new action to create action
eg. when i click on new Post it look up for new action,now it render _form,but when at time of submit how data entered to that particular table, where the create action of controller called and how ?
My posts_controller is as
def new
@post = Post.new
@post.user_id = current_user.id
@post.save
respond_to do |format|
format.html # new.html.erb
format.json { render json: @post }
end
end
# GET /posts/1/edit
def edit
@post = Post.find(params[:id])
authorize! :manage, @post
end
# POST /posts
# POST /posts.json
def create
@post = Post.new(params[:post])
respond_to do |format|
if @post.save
format.html { redirect_to @post, notice: 'Post was successfully created.' }
format.json { render json: @post, status: :created, location: @post }
else
format.html { render action: "new" }
format.json { render json: @post.errors, status: :unprocessable_entity }
end
end
end