I am new to ruby on rails. I am originally a PHP/mysql programmer. I can not seem to understand how you connect any posts to the user and display them (e.g. a post is successfully created with the user ID and then the users ID is queried to get his or her name.)
I am using devise for authentication.
def create
poll = current_user.polls.build(params[:poll])
poll.onefourty = poll.onefourty[0..140]
poll.created_at = Time.now
poll.save!
if @poll.save
redirect_to root_path
else
redirect_to root_path
end
end
<%= form_for Poll.new, :html => { :multipart => true } do |f| %>
Question Option One Option Two Option Three Option Four "next", :value => "" %><% end %>
create_table "polls", :force => true do |t|
t.text "onefourty"
t.string "option1"
t.string "option2"
t.string "option3"
t.string "option4"
t.string "option5"
t.string "option6"
t.datetime "created_at"
t.datetime "updated_at"
t.string "photo1_file_name"
t.string "photo1_content_type"
t.integer "photo1_file_size"
t.datetime "photo1_updated_at"
t.string "photo2_file_name"
t.string "photo2_content_type"
t.integer "photo2_file_size"
t.datetime "photo2_updated_at"
t.string "photo3_file_name"
t.string "photo3_content_type"
t.integer "photo3_file_size"
t.datetime "photo3_updated_at"
t.string "photo4_file_name"
t.string "photo4_content_type"
t.integer "photo4_file_size"
t.datetime "photo4_updated_at"
end
create_table "users", :force => true do |t| t.string "email", :default => "", :null => false t.string "encrypted_password", :limit => 128, :default => "", :null => false t.string "password_salt", :default => "", :null => false t.string "confirmation_token" t.datetime "confirmed_at" t.datetime "confirmation_sent_at" t.string "reset_password_token" t.string "remember_token" t.datetime "remember_created_at" t.integer "sign_in_count", :default => 0 t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" t.string "current_sign_in_ip" t.string "last_sign_in_ip" t.datetime "created_at" t.datetime "updated_at" t.string "username" t.string "firstname" t.string "lastname" t.string "avatar_file_name" t.string "avatar_content_type" t.integer "avatar_file_size" t.datetime "avatar_updated_at" end