Q:

Error occurs: undefined method `+' for nil:NilClass

Working on Rails application. Actually, I'm trying to combine three data into one column. However, an error occurs...
undefined method `+' for nil:NilClass

apps/views/stores/new.html.erb
<%= form_for(@seat) do |f| %>
  <div class="formItem">
    <p>Hours</p>
    <%= f.fields_for :open_hours do |h| %>
      <div id="links">
        <p class="addition"><%= link_to_add_association "Add hour", f, :open_hours, partial: 'hour' %></p>
      </div>
    <% end %>        
  </div>
  <div class="formBtn">
     <%= f.submit "Submit", class: "btn" %>
  </div>
<% end %>

apps/views/stores/_hour.html.erb
<div class="nested-fields">
  <div class="formField">
    <%= f.select :weekday, [['Monday', 1], ['Tuesday', 2], ['Thursday', 3]] %>
    <%= f.select :started_at, [['10:00 am', 1], ['11:00 am', 2], ['12:00 am', 3]] %>
    <%= f.select :ended_at, [['1:00 pm', 1], ['2:00 pm', 2], ['3:00 pm', 3]] %>
    <p><%= link_to_remove_association "Remove hour", f %></p>
  </div>
</div>

apps/modes/open_hour.rb
class OpenHour < ApplicationRecord
  belongs_to :store
  before_save :set_hour

  attr_accessor :weekday
  attr_accessor :started_at
  attr_accessor :ended_at

  private

  def set_hour
    self.hour = self.weekday + "&nbsp;&nbsp;" + self.started_at + "&nbsp;-&nbsp;" + self.ended_at
  end
end

What's the matter?

A:

There are a few potential issues. 

You are using the cocoon gem and should permit the :_destroy attribute (because you have link_to_remove_association). 
You have attr_accessor's for what seems like columns in the open_hours table. The model inherits from ApplicationRecord so this is not necessary....assuming these are columns. 
You have a private method named set_hour. What is self in this situation? Are you wanting this to be a setter? It seems like you are trying to create a virtual attribute before the record itself is saved. 
Most importantly, you should store weekday, started_at, and ended_at individually (which I'm sure you are already doing)...then just use a view helper to display their values in your view. 

