ruby on rails - Why is this ERB code in a fixture throwing 'undefined method'? -
I try to use fixtures to add more complex test data to test specific scenarios with front end I'm in Flex, I'm not sure that this is the right way to go with the rail. My train app is a card game and 'more complex test data' I am trying to test different combinations of cards
For example, I want to set a test game where players have 1 card in hand B and C, where I have specifically added cards to B and C in the hands of the players.
I have basic fixtures for players, sports and users who are working fine for a while. I have tried to add the following ERB code compared to the games, to start the game. Start method, and getting
NoMethodError: The 'game' for the undefined method main: Object
is the stability code snippet:
< Pre> four: id: 4 num_players: 3 turn_num: 0 status_id: 1 & lt;% game_four = games (: four). Game_four.start% & gt;
game_four = games (: four). First
< / Ex>Sports methods are only in test cases, not in fixtures. You should either ask the database or use the links. This is just an example.
four: id: 4 num_players: 3 turn_num: 0 status_id: 1 & lt;% Game.find_by_name (four) .start% & gt;
In addition, it is not really the right place for such a command. The fixtures do not intend to "start playing", you should definitely take this order out of elsewhere, possibly in the case of a dedicated trial within the setup block.
Edit:
I post a comment here, on the original reply with a link to the new Rail Database Seeding feature: First day
This is explained by Yehuda Katz's answer and, of course, the best way to solve this problem.
Comments
Post a Comment