I have model "Post". And the form for creating new record.
<%= form_for(@post) do |f| %>
<% if @post.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2>
<ul>
<% @post.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :title %><br>
<%= f.text_field :title %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
And I have variabe vote of Post which I want set default value 1. How can I do it?
My migration with change_column_default
class CreatePosts < ActiveRecord::Migration
change_column_default :posts, :suit, false
change_column_default :posts, :vote, 1
def change
create_table :posts do |t|
t.string :title
t.string :url
t.string :tags
t.boolean :suit
t.integer :vote
t.timestamps null: false
end
end
end