around this issue The query User.joins(:cars).where('cars.color' => "blue") returns an ActiveRecord::Relation instance. Check docs here. If you really want to operate over an instance (of User class), you must take a user from that collection, for example:
should help you out There's not a valid? method for an ActiveRecord collection. If you're trying to test that the last Ticket you created is valid, you can do something like assert @ticket.valid?. I think you might be doing a bit too much work in your setup method. You could try to just setup your User and Event model in the setup, and break the rest of what you described into different test blocks.
ruby on rails undefined method 'valid' when using update
I wish did fix the issue. ActiveRecord update(id, attributes) Updates an object (or multiple objects) and saves it to the database, if validations pass. The resulting object is returned whether the object was saved successfully to the database or not.
@user = User.find(params[:id]) //Find user
if @user.update(user_params) // Update user if validations pass
flash[:errors] = @user.errors.full_messages