My website uses PostgreSQL and its full-text search. For that to work, I
need to execute some configuration queries in order to configure some
full-text search extensions.

This is what I have written in my seeds.rb file to configure the
development database:

ActiveRecord::Base.connection.execute("CREATE EXTENSION unaccent;")
ActiveRecord::Base.connection.execute("ALTER TEXT SEARCH DICTIONARY unaccent (RULES='unaccent');")
ActiveRecord::Base.connection.execute("CREATE TEXT SEARCH CONFIGURATION es ( COPY = spanish );")
ActiveRecord::Base.connection.execute("ALTER TEXT SEARCH CONFIGURATION es
ALTER MAPPING FOR hword, hword_part, word
WITH unaccent, spanish_stem;")

This works perfectly in develpment.

Now I want to run some search tests, but when I execute my functional
tests, I get an error saying that the extension is not configured:

ActiveRecord::StatementInvalid: PG::Error: ERROR: function unaccent(text) does not exist

So I assume I have to do the same that I did for development, but for the
test environment.

How can I do it in a clean way?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/pVLjZCgazGcJ.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Rob Biedenharn at Oct 24, 2012 at 12:23 pm
    RAILS_ENV=test rake db:migrate

    Or you might have to specify:
    RAILS_ENV=test rake db:migrate:up VERSION={put your migration number here}

    It's likely that the normal db:test:prepare task doesn't support these extensions.

    -Rob
    On Oct 24, 2012, at 6:08 AM, David M wrote:

    My website uses PostgreSQL and its full-text search. For that to work, I need to execute some configuration queries in order to configure some full-text search extensions.

    This is what I have written in my seeds.rb file to configure the development database:

    ActiveRecord::Base.connection.execute("CREATE EXTENSION unaccent;")
    ActiveRecord::Base.connection.execute("ALTER TEXT SEARCH DICTIONARY unaccent (RULES='unaccent');")
    ActiveRecord::Base.connection.execute("CREATE TEXT SEARCH CONFIGURATION es ( COPY = spanish );")
    ActiveRecord::Base.connection.execute("ALTER TEXT SEARCH CONFIGURATION es
    ALTER MAPPING FOR hword, hword_part, word
    WITH unaccent, spanish_stem;")
    This works perfectly in develpment.

    Now I want to run some search tests, but when I execute my functional tests, I get an error saying that the extension is not configured:

    ActiveRecord::StatementInvalid: PG::Error: ERROR: function unaccent(text) does not exist
    So I assume I have to do the same that I did for development, but for the test environment.

    How can I do it in a clean way?


    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/pVLjZCgazGcJ.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedOct 24, '12 at 10:08a
activeOct 24, '12 at 12:23p
posts2
users2
websiterubyonrails.org
irc#RubyOnRails

2 users in discussion

Rob Biedenharn: 1 post David M: 1 post

People

Translate

site design / logo © 2021 Grokbase