Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8202241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:06:41+00:00 2026-06-07T07:06:41+00:00

The test I’m writing is checking to see if I can delete an assignment

  • 0

The test I’m writing is checking to see if I can delete an assignment or not. I thought I’d check for the presence of the link itself first:

describe "Deleting an assignment" do
        before{ visit assignments_path }
        it{ should have_selector('th', text: "Band Member") }
    end

Now when I load the page itself it renders perfectly without any errors (haven’t tried pushing to Heroku yet), but the testing environment returns:

Failures:

  1) Assignment pages Deleting an assignment 
     Failure/Error: before{ visit assignments_path }
     ActionView::Template::Error:
       undefined method `name' for nil:NilClass

the code that’s causing the error is in my assignment stub

<td><%= assignment.user.name + " " + assignment.user.surname%></td>

My assignments controller’s index action is simply:

  def index
  @assignments = Assignment.all
  end

I can’t see anything obvious so any help would be appreciated. Thank you in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T07:06:44+00:00Added an answer on June 7, 2026 at 7:06 am

    It turns out that the first instance of a user created in the test environment was 31 not 1. This was because I was creating a set of 30 users in another test suite but deleting the users afterwards (hence why user 1 didn’t exist). I got around this by assigning the role using a call rather than hard coding what I thought was the ID.

    @assignment = Assignment.create(user_id: @user.id, role_id: @roleSecond.id)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Test string: the%20matrix%20 How can I delete the last three chars? Using this code
test.sh parameter in test.sh , how can I get the parameter ?
Test Driven Development (TDD) and its benefits are well defined. The same can be
test.php?t=xxx,y=sss This is how the user inputs data to my script. How can I
test login logout user is not online do get :login, :id=>1 before = User.find(1).is_online
TEST SITE Look here to see code in action I have two arrays which
test code is: console.log(true && abc);//abc who can tell me why the result is
test = function(x){ if ( some conditions ) { return true; } else {
#test code: #!/bin/bash #~/test/test.sh trap echo 'testmessage' DEBUG while : do echo abc sleep
test.c: int main() { return 0; } I haven't used any flags (I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.