Ruby on Rails Tuesday, September 2, 2014



do you know how to tail the development log (I assume not because you are using puts statements instead of logger.debug statements). You probably want to get used to using logger.debug(x.inspect)   (where x is the variable you want to look at) for debugging.

Please tail the development log and show us the controller action & parameters (copy and paste the whole thing for us). 

I recommend using http://gist.github.com for sharing code.

Also, when asking for help, show us the entire Controller code, beginning with the class definition. (you did not specify if the code is inside of an action)

To debug your problem, you need to know what the value of game_params is, which you did not show us. 

-Jason




On Sep 2, 2014, at 4:15 PM, Adrien R. <lists@ruby-forum.com> wrote:

Hello,

I'm having an error I don't understand for several days. I have a class
Game, which have 2 attributes :
class Game < ActiveRecord::Base
 has_many :players
 has_many :cards, as: :cardable


Then I create a new instance and access the players it fails with void
value expression.

@game = Game.new(game_params);
puts "cards"
puts @game.cards
puts @game.cards.size()
puts "players"
puts @game.players

It displays:
cards
0
players

And it fails with: "void value expression" on the last line.

A few days ago this code worked just fine, I don't know what changed and
how to understand how to fix it.

Thank you.

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f17aacbad6ed08d697bac0440966afb8%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.


No comments:

Post a Comment