조리법 웹 앱을 만들려고합니다. 그것은 일종의 "게임"입니다. 각 사용자는 조리법을 좋아할 가능성이 있습니다. 처음에는이 것이 비어있는 것처럼 보입니다. 그리고 나서, 사용자는 각 시간 (또는 30 분) 간격으로, 조리법의 각 단계를 수신하기로되어 있습니다.레일에서 특정 게시물 간의 시간 간격을 만드는 방법은 무엇입니까?
def index
@recipe = Recipe.find(params[:recipe_id])
@steps = @recipe.steps
end
그리고 내 인덱스 단계보기에 표시 할 것입니다 : 내가 가진
class Recipe < ApplicationRecord
belongs_to :user
has_many :steps
has_many :favorites
has_many :favorited_by_users, :through => :favorites, :source => 'user'
class Step < ApplicationRecord
belongs_to :recipe
end
class Favorite < ApplicationRecord
belongs_to :recipe
belongs_to :user
end
class User < ApplicationRecord
has_many :recipes
has_many :favorites
has_many :favorite_recipes, :through => :favorites, :source => 'recipe’
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
end
내 단계 컨트롤러에서 :
순간, 나는이 모델을 가지고 사용자가 좋아하는 레서피의 각 단계, 하나씩 지연 (각 출판물간에 1 백만 또는 10 백만개 ... 무엇이든 구성 가능한 것). 그리고 단계의 이름을 숨기고 그것을 클릭 한 후 표시 할 수 있습니까? 기타
#views/steps/index.html.erb
<h2><%=Recipe.name%></h2>
<% @steps.each do |step| %>
<p> <%=step.name%></p>
#30mn later… the second step
<p> <%=step.name%></p>
#30mn later… the third one…
<p> <%=step.name%></p>
...
어떻게 가능할까요? cron 또는 Active Job을 사용해야합니까? 하지만 어떻게해야합니까?
미리 감사드립니다. ;)
가 감사를 등록 할 문제이다! ;) 나는 이것을 시도 할 것이다;) – Mehdi007
@ Mehdi007 환영합니다! 만약 당신이 (미래의 검색을 위해) – AntonTkachov
안녕하세요, 그냥 모든 질문을 렌더링 후 모든 단계를 렌더링 후 자바 스크립트를 실행하는 데 도움이 될 것입니다 내 코드를 틱으로 유효한 응답으로 표시하는 것이 좋을 것입니다 어떻게 그 후에 피할 수 있습니다 페이지가 다시로드되면 매번 1 단계부터 시작됩니까? – Mehdi007