<% if @article.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@article.errors.count, "error") %> prohibited this article from being saved:</h2>
<ul>
<% @article.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
# project.rb
has_many :tasks
# вызывать так
project = Project.first
project.tasks # список всех тасков у проекта
project.tasks.create({ ... }) # создание нового таска
rvm get stable
rvm reinstall 2.1.1
rake secret
secret_key_base: <%= ENV['SECRET_KEY_BASE'] || 'my_super_secret_code1231243512' %>
# Enumerable status
STATUS = {
0 => :waiting,
1 => :finished,
2 => :expired,
3 => :removed
}
STATUS.each do |key, status|
define_method "#{status}!" do
self.status = key
self.save
end
define_method "#{status}?" do
self.status == key
end
end
def status?
STATUS[self.status]
end
object.finished! # status = 1
object.waiting? # false
object.waiting! # status = 0
object.waiting? # true
object.status? # waiting
<%= render 'view' %>
setInterval(function() {
$("#refresh").load(location.href+" #refresh>*","");
}, 10000);