Pregunta

¿Cómo se prueba un tema de modelo que acepta atributos anidados para una imagen?

Given /^I have topics titled (.+)$/ do |titles|
    path ="#{RAILS_ROOT}/features/upload-files/" 
    image = File.new(path + "image.jpg")
    titles.split(', ').each do |title|
        Topic.create!(:title => title, :image => File.new(image) ) # this doesn't work!
    end
end
¿Fue útil?

Solución

Topic.create!(:title => title, :image_attributes => {:image => File.new(image) } ) # this works!
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top