私はレシピのWebアプリケーションを構築しようとします。これは一種の「ゲーム」です。各ユーザーはレシピを気に入る可能性があります。最初は、これは空に見えます。そして、ユーザーは各時間(または半時間)を間隔、すなわちレシピの各ステップで受け取ることになっています。レールで特定の出版物間の時間間隔を作成するにはどうすればよいですか?
瞬間のために、私はこれらのモデルを持っている:
私は私のステップコントローラで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
:
def index
@recipe = Recipe.find(params[:recipe_id])
@steps = @recipe.steps
end
そして、私は私のインデックスステップビューに表示したいと思います:
ユーザーが気に入ったレシピの各ステップ、遅れて1つずつ(各出版物の間には1mnまたは10mn ...何か設定可能なもの)。ステップの名前を隠してクリックして表示することは可能ですか?その他、各種
#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つの質問は、すべての手順をレンダリングした後、それを表示するjavascriptを実行した後、ページのリロードは、毎回ステップ1から始まりますか? – Mehdi007