You'd be best setting it up like this:
#app/models/user.rb
Class User < ActiveRecord::Base
has_many :schedules
end
#app/models/schedule.rb
Class Schedule < ActiveRecord::Base
belongs_to :user
end
Then your tables could be constructed as such:
#schedules
id | user_id | titel | location | time | created_at | updated_at
This means that you can do this:
#config/routes.rb
resources :users, only: :index
#app/controllers/users_controller.rb
def index
@schedules = current_user.schedules
end
#app/views/users/index.html.erb
<%= for schedule in @schedules do %>
<strong><%= schedule.titel %></strong>
<%= schedule.time %>
<%= schedule.location %>
<% end %>
This will output a list of schedules / appointments for your user. In order to get the grouped effect, you'll have to use the likes of group_by
in your controller