Rails fixtures - table name definition?

At the moment when all my fixtures have the same name as the table for which they are intended, due to a recent problem with the rails, it seems that there can be no equipment starting with the word "test"

Does anyone know a way to have a different device name and then map it to the correct table?

Thanks Andy

+5
source share
3 answers

This blog post is similar to what you want to do.

0
source

You can set the class of this device manually as follows:

class SomeTest < ActiveSupport::TestCase

  set_fixture_class widgets: 'Module::ClassInAModule'
  fixtures :widgets # or fixtures :all if you’ve defined all the mappings required

  test 'widgets can be found' do
    assert Module::ClassInAModule.all.any?, 'there should be widgets'
  end

end

, , - .

+3

:

class Anywhere < ApplicationRecord
    self.table_name = "singular_table"
end
0

All Articles