前提・実現したいこと
hamlを用いてWebページのデザインをしています。入れ子構造ではなく、@tweet.text自体にclassを設定したいです。(一応、コントローラも載せておきます)
= @tweet.text, class: 'box__text'と指定すると以下のエラーが発生します。
入れ子構造ではなく、@tweet自体にクラスを設定する方法がわかるかた、ご教示お願いいたします。
発生している問題・エラーメッセージ
SyntaxError in TweetController#show /Users/yuna/my_projects/new_application/app/views/tweet/show.html.haml:4: syntax error, unexpected tLABEL, expecting ')' ...cape((( @tweet.text, class: 'box__text' ... ^~~~~~ .box = image_tag @tweet.image.to_s, class: 'box__picture' = @tweet.text, class: 'box__text'
該当のソースコード
html
1.wrapper 2 .box 3 = image_tag @tweet.image.to_s, class: 'box__picture' 4 = @tweet.text, class: 'box__text' 5 6
該当のソースコード
ruby
1def create 2 @tweet = Tweet.create(image: tweet_params[:image], text: tweet_params[:text], user_id: current_user.id) 3 redirect_to tweet_index_path 4 5 end 6 7
試したこと
ロケット記法など、classの書き方を複数試しましたが、正常にクラス指定はできませんでした。。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/07/03 06:58