Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- When(/^I select a student$/) do
- click_on "#{@student.first_name} #{@student.last_name}"
- end
- Then(/^I should see their information$/) do
- expect(page).to have_content(@student.first_name)
- end
- Scenario: See Individual Student Page
- Given I am logged in as a flatiron employee
- When I visit the students page
- And I select a student
- Then I should see their information
- class CoursesController < ApplicationController
- def index
- @courses = Course.all
- end
- def new
- @course = Course.new
- end
- def create
- @course = Course.new(course_params)
- if @course.save
- flash[:notice] = "Course has successfully been saved."
- redirect_to course_path(@course)
- else
- flash[:notice] = "Error! Course was not successfully saved."
- redirect to new_course_path
- end
- end
- def show
- @course = Course.find(params[:id])
- end
- private
- def course_params
- params.require(:course).permit(:name)
- end
- end
- class StudentsController < ApplicationController
- before_filter :set_student, only: [:show, :edit, :update, :destroy]
- def index
- @students = Student.all
- end
- def show
- end
- def new
- @student = Student.new
- end
- def edit
- end
- def create
- @student = Student.new(student_params)
- if @student.save
- flash[:notice] = "Student form successfully submitted."
- redirect_to students_path
- else
- flash[:error] = "Unable to process your request."
- render :new
- end
- end
- def update
- Student.update(@student, student_params)
- redirect_to student_path(@student)
- end
- def destroy
- @student.destroy
- redirect_to courses_path
- end
- private
- def set_student
- @student = Student.find(params[:id])
- end
- def student_params
- params.require(:student).permit(removed_attributes)
- end
- end
- Registrar::Application.routes.draw do
- resources :courses do
- resources :students, controller: :courses_students, only: [:new, :create, :show]
- end
- resources :students
- devise_for :users, :path_names => { sign_in: 'login', sign_out: 'logout' }, :controllers => {
- :omniauth_callbacks => "users/omniauth_callbacks",
- :sessions => "sessions"
- }
- root 'pages#landing'
- end
- <br><br>
- <%= @student.first_name %>
- <%= @student.last_name %><br>
- <br>
- <%= link_to "Back to Course", course_path(@student.course) %>
- <%= link_to "Students", students_path %>
- <br>
- <br><br>
- <% @students.each do |student| %>
- <%= link_to "#{student.first_name} #{student.last_name}", student_path(student) %><br>
- <% end %>
- <br>
- <%= link_to "Landing Page", root_path %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement