Thinking-Sphinx-Raspell configuration - ruby-on-rails

I am using rails 2.3.4 and sphinx 1.4.4 and raspell 1.0.0. Now I would like to
add fuzzy match in sphinx search, so I added in my config/environment.rb file I added the following lines:
config = ThinkingSphinx::Configuration.instance
config.raspell.dictionary = 'en'
config.raspell.suggestion_mode = :badspellers
Ref - https://github.com/freelancing-god/thinking-sphinx-raspell
while starting my server it throws the error like this
undefined method `raspell' for
#<ThinkingSphinx::Configuration:0xb63d7f8c> (NoMethodError)
Can you help me on this?

What happens if you shift that configuration to an initialiser? And do you have it currently at the top or the bottom of config/environment.rb? It should be at the bottom, outside of Rails' own configuration block (gems aren't loaded until the block is processed).

This is the problem because of the gem versions.
I modified gem versions this issue is fixed now.
Here the Gems and its versions:
Thinking sphinx - 1.3.17
Active Record - 2.3.5
After Commit - 1.0.10
Riddle - 1.0.10
Thinking sphinx Raspell - 1.1.1
Raspell -1.3

Related

What's the replacement for acts_as_commentable in Rails 6, Ruby 3.0.2?

I upgraded our app to Rails 6.1.4.4 and Ruby 3.0.2. I have this old gem
gem 'acts_as_commentable'
Locked at version 4.0.2. The gem does not appear to be supported anymore, which is a shame because when I start up my app or console, I now get this error
$ rails c
Your Gemfile lists the gem rspec-rails (>= 0) more than once.
You should probably keep only one of them.
Remove any duplicate entries and specify the gem only once.
While it's not a problem now, it could cause errors if you change the version of one of them later.
/Users/myuser/.rvm/gems/ruby-3.0.2/gems/hash_dot-2.5.0/lib/hash.rb:19:in `method_missing': undefined method `arity' for {:as=>:commentable, :dependent=>:destroy}:Hash (NoMethodError)
from /Users/myuser/.rvm/gems/ruby-3.0.2/gems/activerecord-6.1.4.4/lib/active_record/associations/builder/association.rb:53:in `build_scope'
from /Users/myuser/.rvm/gems/ruby-3.0.2/gems/activerecord-6.1.4.4/lib/active_record/associations/builder/association.rb:47:in `create_reflection'
from /Users/myuser/.rvm/gems/ruby-3.0.2/gems/activerecord-6.1.4.4/lib/active_record/associations/builder/association.rb:32:in `build'
from /Users/myuser/.rvm/gems/ruby-3.0.2/gems/activerecord-6.1.4.4/lib/active_record/associations.rb:1458:in `has_many'
from /Users/myuser/.rvm/gems/ruby-3.0.2/gems/acts_as_commentable-4.0.2/lib/commentable_methods.rb:58:in `acts_as_commentable'
…
Is there any simple replacement for this gem or way to monkey-patch this error so I can start up the app?
Looking over the forks, I found this one that appears to work for me using Rails 6.0.6 and Ruby 3.0.5.
https://github.com/alazycoder101/acts_as_commentable.git
I have not tested it extensively yet, but at least the basic functionality seems to be working for me. Hope this helps.
For clarity, to use that fork you would use the following line in your Gemfile:
gem 'acts_as_commentable', git: 'https://github.com/alazycoder101/acts_as_commentable.git'

rails6 app: minitest failing with ActionView::Template::Error: uninitialized constant

A bit of a puzzler - I've got an app using a very simple gem I wrote (UIAvatars) to generate a URL to an Avatar API. This demonstrably working in my Development rails app (the Avatar is displayed with no issues) but when I try to run my controller tests it causes errors like so:
Error:
InitiativesControllerTest#test_should_get_new:
ActionView::Template::Error: uninitialized constant ProfilesHelper::UIAvatars
app/helpers/profiles_helper.rb:17:in `profile_image_link_for'
app/views/layouts/_header.html.erb:62
app/views/layouts/application.html.erb:23
test/controllers/initiatives_controller_test.rb:15:in \`block in <class:InitiativesControllerTest>'
The method in profiles_helper is:
def profile_image_link_for(profile, **options)
image_tag(
UIAvatars.generateURL(name: profile.full_name, size: "128", background: "random"),
options
).html_safe
end
bundle says it is installed:
% bundle info ui_avatars
* ui_avatars (0.0.1)
Summary: Generate avatars with initials from names using https://ui-avatars.com
Homepage: https://rubygems.org/gems/ui_avatars
Path: /Users/thatsme/.rvm/gems/ruby-2.6.6/gems/ui_avatars-0.0.1
it's in my Gemfile in the default group
gem 'ui_avatars'
Any idea what could be causing this problem?
Answer is that .ruby-version had a different version of ruby (2.6.7) than I was actually using (2.6.6) and so ruby could not find the gem installed in the expected path when running minitest.
(why it still worked in rails is a question for another day).

MongoMapper and Joint Plugin giving issues

I am using mongo_mapper (0.10.1, 0.9.2) and joint (0.6.0, 0.4) in Ruby 1.9.2 and when ever I try to add the "plugin Joint" to one of my models I get an error. Specifically:
ArgumentError: Plugins must extend ActiveSupport::Concern
from /.rvm/gems/ruby-1.9.2-p290/gems/mongo_mapper 0.10.1/lib/mongo_mapper/plugins.rb:11:in `plugin'
I added joint to my gem file and I am just having a hard time pinning down this error. Any help would be appreciated.
The problem was with dependency issues in that version of Joint. The remedy to the problem was to require the gem from the git to get the latest version which had a dependcy fix for mongomapper 0.10.1 because the other Joint only supported up through 0.9.x
gem 'joint', :git => "git://github.com/jnunemaker/joint.git"

Ruby on Rails, LinkedIn:Module error

Has any one come across this error?
NoMethodError (undefined method `new' for LinkedIn:Module)
I think it's related to omniauth and linkedin. Here's my Gemfile:
gem 'omniauth'
gem 'linkedin', :git => "git://github.com/redbeard-tech/linkedin.git", :branch => 'jsapi'
I'm using:
ruby 1.8.7 (2010-01-10 patchlevel 249)
rails 3.0.5
What might be the reason for it?
Check what version of omniauth you are using. We recently ran into this and it was from our dev environment having omniauth 0.3.x and the new environment getting the new 1.0 release. On the omniauth github site it says:
OmniAuth 1.0 has several breaking changes from version 0.x. You can set the dependency to ~> 0.3.2 if you do not wish to make the more difficult upgrade. See the wiki for more information.
I suspect you're being bitten by that.
From the error message it looks like you are calling LinkedIn.new(...), but looking at the documentation it seems like it should be LinkedIn::Client.new('your_consumer_key', 'your_consumer_secret'). LinkedIn is a module, not a class and therefore doesn't have a new method. However, there seems to be class called Client defined within this module, which you have to instantiate.

Couldn't find 'devise_install' generator - Rails 2.3.8, Devise 1.0.8

I'm trying to get Devise up and running with a freshly generated Rails
2.3.8 app.
This is the error I'm running into:
devise > script/generate devise_install
Couldn't find 'devise_install' generator
I do have the Devise and Warden gems specified in my config file:
config.gem 'warden', :version => '0.10.7'
config.gem 'devise', :version => '1.0.8'
The gems are installed:
devise > rake gems
- [I] warden = 0.10.7
- [R] rack >= 1.0.0
- [I] devise = 1.0.8
- [I] warden ~> 0.10.3
- [R] rack >= 1.0.0
I = Installed
F = Frozen
R = Framework (loaded before rails starts)
Looking at the list of generators, I don't see anything from Devise:
devise > script/generate
Installed Generators
Rubygems: cucumber, facebook, facebook_controller,
facebook_publisher, facebook_scaffold, feature, integration_spec,
publisher, rspec, rspec_controller, rspec_model, rspec_scaffold,
session, xd_receiver
Builtin: controller, helper, integration_test, mailer, metal,
migration, model, observer, performance_test, plugin, resource,
scaffold, session_migration
Any clues?
in 1.1.5 its
rails generate devise:install. I have seen devise_install in some tutorials.
I ran into the same problem myself and, unfortunately, didn't ever get it fixed. But I did manage to find a pretty simple workaround.
The tasks the generators perform are typically pretty straightforward. So manually reproducing the same result shouldn't be a big deal if you just take a look at the generator code.
The devise_install generator in your example above just copies devise.rb to config/initializers/devise.rb and en.yml to config/locales/devise.en.yml
If you take a look at the other generators I'm sure you can figure them out easily enough as well.
The same problem occurred with me, because I'm already had installed devise (a version ahead of 1.0.8). I just uninstall the devise ahead version.
Now my enviroment has only devise 1.0.8 and it works very well. :)
seems to be working using devise 1.0.7

Resources