LoginSignup
0

More than 3 years have passed since last update.

Rails Simple Calendarで記事投稿後、カレンダーに反映させたい。

Last updated at Posted at 2020-07-25

Simple Calendarにて
記事投稿→カレンダー投稿画面(create)→カレンダーに反映という事を行いたいのですが、
現状、記事投稿は出来ていて、そこから記事投稿のタイトルデータを抜き出してカレンダー投稿画面にタイトルのみデータを表示取得させたいです。
540d264cf48615032c7353a06dffbdf6.png
※こちらの画面ではTitleが入力フォームになっていますがこのTitleを、記事のTitleを取得したいです。

試した事ですが
5336e6a17d83d2db786feb63021d995c.png

1、
- @tweets.each do |tweet|
= @tweet.title
を入力しましたが
d2cf2caa748b7b3ad991e29b02e302bb.png

このようなエラーが出ました。

blog(カレンダー)とtweet(記事)のアソシエーションとして
4c606c184b85049ae3185dc556a08022.png
025a6b6e9003a3707599aa75945c6d5e.png

はこのように組んでいます。

blogのdb(データベース)はこちらになります。

create_table :blogs do |t|
  t.string :title
  t.text :content
  t.datetime :start_time

  t.references :user, foreign_key: true
  t.references :tweet, foreign_key: true
  t.string :tweet_title
  t.timestamps
end

blog_controllerはこちらになります。

19b8126718b90974d1a4db94d7d11982.png

記事投稿の際に他のページだとビューの表示は出来ました。
52b32613dc3a1aa18170323ae8d61abe.png
db9032b4f568d364a6a228d3c5415f0b.png

ご回答いただければ幸いです。
未熟者ですがよろしくお願いします。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0