localhost
localhost

Reputation: 1082

If Statement Causing Undefined Local Variable/Method

Why would adding this HAML if statement return 'ftp' as an undefined local variable/method? When I remove the if/else statement everything runs as it should.

- if @contest.size > 2
  / Do stuff
- else
  - team.fantasy_team_players.each do |ftp|
    - player = @owned[ftp.id]
    .col-md-6
      = "Words..."
      = ftp.position

Update

Adding the correct indentation fixed the undefined error. However, .col-md-6 doesn't render when the page is loaded. Any thoughts as to why that's happening?

Upvotes: 0

Views: 144

Answers (1)

Roman Kiselenko
Roman Kiselenko

Reputation: 44370

Indentation on your haml views should be:

- if @contest.size > 2
  / Do stuff...
- else
  - team.players.each do |ftp|
    .col-md-6
      = ftp.position

Upvotes: 2

Related Questions