On 28 December 2014 at 10:08, Bazley <[email protected]> wrote:
> I have the following error:
>
> ERROR["test_character_should_be_valid", CharacterTest, 0.214787]
> test_character_should_be_valid#CharacterTest (0.21s)
> NoMethodError:         NoMethodError: undefined method `val' for
> "$1":Arel::Nodes::BindParam
> app/models/user.rb:11:in `block in <class:User>'
> test/models/character_test.rb:8:in `setup'
>
> From the following test: test/models/character_test.rb:
>
>     require 'test_helper'
>
>     class CharacterTest < ActiveSupport::TestCase
>
>       def setup
>         @user = User.new(name: "Example User", email: "[email protected]",
> callsign: "example",
>                          password: "foobar", password_confirmation:
> "foobar")
>         @user.save
>         @character = @user.character
>       end
>
>       test "character should be valid" do
>         assert @character.valid?
>       end
>
>     end # CharacterTest
>
> In the gemfile:
>
> gem 'arel', '6.0.0.beta2'
>
> character.rb:
>
> class Character < ActiveRecord::Base
>   belongs_to :sociable, polymorphic: true
> end
>
> user.rb:
>
> class User < ActiveRecord::Base
>
>   has_one  :character, as: :sociable
>
>   before_validation do
>     self.create_character unless character
>   end
>   .
>   .
> end

You have not told us which is line 11 in user.rb, which is the line it
says the error is on.

Colin

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLse70L9NJfiy%2B3TW38-S0o%3DySyy%2B%3Dm%2BVU9xfrgF%2BQ0VpQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to