0

私はこのフォームを何年も機能させようとしてきましたが、機能していないようです。最も厄介なのは、すべてが正常に動作しているように見えるのに、データベースに何も表示されないことです。

コントローラ:

def create
  @post = Post.new(params[:post])
  respond_to do |format|
    if @post.save!
      format.html { redirect_to @post, notice: 'Lesson 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

モデル

attr_accessible  :userID, :groupID, :postTime, :postText

投稿を表示

#uploadStyle
    = form_for Post.new do |f|
      = f.label :postText, 'PostText'
      = f.text_area :postText
      %br
      = f.label :postTime, 'PostTime'
      = f.text_area :postTime
      %br
      = f.label :userID, 'UserID'
      = f.text_area :userID
      %br
      = f.label :groupID, 'GroupID'
      = f.text_area :groupID
      %br
      = submit_tag 'Submit'

ログ

Started POST "/posts" for 127.0.0.1 at 2013-10-10 22:04:32 -0700
Processing by PostsController#index as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"AUq6mt54N7kA67M1L9wQdqhl2UPRxhOEZOv/LSowcJU=", "post"=>{"postText"=>"work please", "postTime"=>"2013-01-01 04:24:23", "userID"=>"1", "groupID"=>"1"}, "commit"=>"Submit"}
Post Load (0.1ms)  SELECT "posts".* FROM "posts" ORDER BY "posts"."id" DESC LIMIT 1
Post Load (0.2ms)  SELECT "posts".* FROM "posts" 
Rendered posts/index.html.haml within layouts/application (12.5ms)
Completed 200 OK in 40ms (Views: 24.8ms | ActiveRecord: 0.7ms)

ルート

  root :to => 'posts#index'
  '/posts' に一致、:to => 'posts#index'

  リソース :posts do
    メンバーは
      投稿「アップロード」
    終わり
  終わり

  match '/posts/:id', :to => 'posts#show', :format => false
  一致 '/add_post', :to => 'posts#add_post'
4

1 に答える 1