V
V
Vladimir2016-09-09 10:18:23
PostgreSQL
Vladimir, 2016-09-09 10:18:23

How to get actual data from the database?

Good afternoon!
There is a code that displays records from a table

def count
  while true
    p Post.all
  end
end

But if a new record is added to the database, then this is not displayed in any way.
How can this limitation be bypassed?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vladimir, 2016-09-09
@zveropasen

Post.uncached do
  ...
end

C
Chronic 86, 2016-09-09
@chronic86

oO nothing is clear why the bike?
ActiveRecord Way
SQL Way
SELECT COUNT(column_name) FROM table_name;

N
Nikolai Turnaviotov, 2016-10-03
@foxmuldercp

well, in the
controller piggy bank: @posts = Post.all
view
<% @posts.all.each do |p| %>
<%= p.title %>
<% end %>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question