ruby on rails - Capybara string-array type fill_in fails with factory-created data -
I have a table table where a person has an array of emails in my schema rbb this looks like this :
create_table "people", force: make true. T | T.string "email", array: true My person-model confirms the presence of email: valid: email, presence: true My People-Controller creates a person like this:
def = person = person.new (person_params) @ person.email & lt; & Lt; Person_param ["email"] # 4 strong parameter to answer. Format | If @ person.save! Format.html {redirect_to people_url, notice: T ('app.people.successful_save')} format.json {Render: index, status :: created} and format.html {render: index} format.json {render json: @ my form.html. Email asking for email:
= f.label: person, T ('app.people.email') = f.text_field: email Factory-piece that creates emails (among other things):
FactoryGirl Factory: Factory: person does not do # other stuff here ... email ["mail1@example.com" "] # ... and other stuff ends here And this is my convenience - SPC that fails:
This is a new one The person is able to create 'person = build (: person)' people Go to 'New person' within 'click' button ("#new_person_form") # Other things going on here ... fill_in 'person_email' ,: with = & gt; Person.email # & lt; ---- Failure here # and other stuff do not pass here, click the button 'Save' to expect (page). For the 'person saved' is the end error message only: failure / error: fill_in 'person_email' ,: with = & gt; Person.email ArgumentError: The value can not be an array when the 'multiple' attribute is not present. No array If I run this message, then I found it: Unfortunately I could not understand it very well. I have probably probed the Kaiserbara cheat sheet for possible mistakes, but I have not done any good.
If I change the person then I have to find out. Email with arbitrariness like this: fill_in 'person_email', with: = with & gt; "Sth.sth@mail.com" I have tried various types of values for the e-mail, including the array bracket in the factory - the same error message appears
When I make an object instead of the creation of a person and in my email-field I use plain string within the factory instead of the array - my model email presence verification fails. But I think that this is logical because in relation to Schema, the model is not getting the string.
I do not have much experience in RSPC yet, so maybe this is a simple mistake. Still need help, thank you!
UPDATE1: Definition of person class: class person & lt; ActiveRecord :: Base Valid: Email, Attendance: Right End
fill_in ' Person_email ',: with = & gt; Person.email This row is actually equal to the following:
find (fillable_field, 'person_email'). Setting (person.email) person.email returns an instance of the error but the person_email field contains the attribute multiple < / Code> is not. This kind of usage does not make any sense, so Carpera raises the error (how can you write several values in a text field?). Perhaps you want to do the following:
fill_in 'person_email', with: person.email.first
Comments
Post a Comment