LoginSignup
0
0

More than 1 year has passed since last update.

[エラー]こんなミスは嫌だ

Posted at

はじめに

本記事では、これまでに学習した中で、
ヒューマンエラー、ケアレスミスをしてしまったことを紹介いたします。
私としても、同じことを繰り返さないために、備忘録としてここに記述します。

ケアレスミス

resources


(正)

resources :prototypes
  resources :prototypes do
    resources :comments, only: :create
  end
resources :users, only: :show

(誤)

resources :prototypes
  resources :prototypes do
    resources :comments, only: :create
resources :users, only: :show
end

usersまでネストしていたため、
Prefixも異なる事態に陥りました。

モデル

(正)model
(誤)medel

見つけた時は、笑いが止まりませんでした。

locals

以前の記事にも、載せましたが、
(誤)local
(正)locals

です。

img src

(誤)img scr
(正)img src

eachメソッド


(正)

<% @prototype.comments.each do |comment| %>

(誤)

<%= @prototype.comments.each do |comment| %>

=をつけるととんでもないぐらいブラウザに情報が飛び交う。
何に=をつけるのか、つけないのか正確に理解する必要があります。

終了タグの抜け

そのままの意味です。

アソシエーション

(正)

belongs_to :user
has_one_attached :image
has_many :comments , dependent: :destroy

(誤)

belong_to :user
has_one_attached :image
has_many :comment , dependent: :destroy

「s」抜け。見つけることは困難を極めます。

render

(正)

 if prototype.save
     redirect_to prototype_path
 else
     render :edit
 end

(誤)

 if prototype.save
     redirect_to prototype_path
 else
     render_to :edit
 end

redirect_toに引っ張られないように。

7つのアクション

new・・・新規投稿ページを表示
create・・・データの投稿を行う

*逆にしない!!

終わり

キリがないので、
これで終わりにします。

とにかくミスが発覚した時は、
例えケアレスだからと言って軽く扱わず、
間違えたことをアウトプットし、なぜ間違えたのかフィードバックを行うよう心がけましょう。

引き続き頑張ります!!

0
0
0

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
0