```ruby
get '/questions/index' do
  if @user.access == 'student'
    json questions: @user.questions
  elsif @user.access == 'coach'
    json questions: Question.all
  end
end

post '/questions' do
  @user.questions << Question.create(params['question'])

  json question: @user.questions.last
end

delete '/questions' do
  Question.find(params['question']['id']).destroy();
end

put '/questions' do
  Question.find(params['question']['id']).update(params['question'])
end```

Check For Initial Ajax Call To Not Fail
user
```ruby
get '/questions/index' do
  return if @user.nil?
  if @user.access == 'student' || @user.access == 'admin' #TODO => MAKE ADMIN PAGE
    json questions: @user.questions
  elsif @user.access == 'coach'
    json questions: Question.all
  end
end

post '/questions' do
  @user.questions << Question.create(params['question'])

  json question: @user.questions.last
end

delete '/questions' do
  Question.find(params['question']['id']).destroy();
end

put '/questions' do
  Question.find(params['question']['id']).update(params['question'])
end```
assistant