SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Nov 2008
    Location
    Germany
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to pass an object to the need template [functional test]

    Action in the Controller:
    def show
    @story = Story.find(params[:id])
    end


    Test:
    def test_should_show_show
    get :show, arams => {:id => 'sitepoint' }
    assert assignsstory).valid?
    end

    This is the Error, that i have..

    test_should_show_show(StoryControllerTest):
    ActionView::TemplateError: You have a nil object when you didn't expect it!
    The error occurred while evaluating nil.name

    I think the action show musst find the objet for me or ?. I'm trying to understand please help me!!!

  2. #2
    SitePoint Member
    Join Date
    Nov 2008
    Location
    Germany
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DerrickFiedler View Post
    Action in the Controller:
    def show
    @story = Story.find(params[:id])
    end


    Test:
    def test_should_show_show
    get :show, arams => {:id => 'sitepoint' }
    assert assignsstory).valid?
    end

    This is the Error, that i have..

    test_should_show_show(StoryControllerTest):
    ActionView::TemplateError: You have a nil object when you didn't expect it!
    The error occurred while evaluating nil.name

    I think the action show musst find the objet for me or ?. I'm trying to understand please help me!!!
    I found the solution, i dont need to give the params hash explixit,
    the solution is: get :show, {:id => 'sitepoint'} and that is :-)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •