I’m at the end of the third lesson and have a problem with the validation of new TextShouts.
The problem is that I’m able to create a Shout with the content type TextShout where the TextShout has no body.
Thus, I get the following error afterwards:
ArgumentError in Dashboards#show
Showing .../thoughtbot/intermediate-rails/app/views/shouts/_shout.html.erb where line #6 raised: 'nil' is not an ActiveModel-compatible object that returns a valid partial path.
The Shout object looks like this:
=> #<Shout id: 27, user_id: 2, created_at: "2013-10-04 10:36:04", updated_at: "2013-10-04 10:36:04", content_type: "TextShout", content_id: nil>
I can also reproduce this in the Rails console:
irb(main):015:0* textshout = TextShout.new => #<TextShout id: nil, body: nil> irb(main):016:0> textshout.valid? => false irb(main):017:0> shout = User.first.shouts.new(content: textshout) User Load (0.3ms) SELECT "users".* FROM "users" LIMIT 1 => #<Shout id: nil, user_id: 1, created_at: nil, updated_at: nil, content_type: "TextShout", content_id: nil> irb(main):018:0> shout.valid? User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1 => true
Does anyone else have that problem? The repo is here if you want to have a look: intermediate-rails