Ferret search not working for my rails app - ruby-on-rails

First, I logged into the ruby script/console -e production and tried to index each table using
Model.rebuild_index
It worked fine and returned true
I then started the ferret server using the command
ruby script/ferret_server start -e production
Then i started my application and it's all working fine except the search. When i try searching on the search tab, i get an error as follows :
Words::BadWordnetDataset in HomeController#search
Failed to locate the wordnet database. Please ensure it is installed and that
if it resides at a custom path that path is given as an argument when
constructing the Words object.
The search is working fine in the console
result = ActsAsFerret.find("admin",[User], :limit => 2) does fetch me results

Installed the copy of the wordnet data files for OS using :
sudo apt-get install wordnet-base
Word is actually derived from Wordnet :
require 'word'
data = Words::Wordnet.new

Nothing surprising
ActiveRecord has no method rebuild-index

Related

Rails environment broke- need help repairing

ugh! In the course of working in my perfectly good rails environment, I did something bad:
While running my local sandbox, looking in Chrome developer tools/sources (this is for our own codebase), I clicked an item in the sources list and doing so prompted downloading a file: Roboto-Regular-e60d1ba1cef90e4a4da5c9e2fe1ec3b1.woff2
I got a "threat detected" popup
I submitted the screen I was on, and saw an error to the effect of 'no data', and rails server had stopped
Now I'm having the following symptoms:
Typing "rails server" (or even just "rails") gives me a "No such file or directory" error for /usr/local/Cellar/rbenv/1.1.1/libexec/rbenv.
the following script (with no modifications since its original create date last year) has the line looking for that file : /.rbenv/shims/rails
in the directory in question (libexec), I don't see a plain "rbenv" file, only these with more specific names: rbenv---version, rbenv-help, rbenv-realpath.dylib, rbenv-version, rbenv-version-origin, rbenv-commands, rbenv-hooks, rbenv-root, rbenv-version-file, rbenv-versions, rbenv-completions, rbenv-init, rbenv-sh-rehash, rbenv-version-file-read, rbenv-whence, rbenv-exec, rbenv-local, rbenv-sh-shell, rbenv-version-file-write, rbenv-which rbenv-global, rbenv-prefix, rbenv-shims, rbenv-version-name
I've just used homebrew to upgrade rbenv, but the symptom is still the same.
My $PATH variable has:
-bash: /Users/drkaplan/.rvm/gems/ruby-2.2.2/bin:/Users/drkaplan/.rvm/gems/ruby-2.2.2#global/bin:/Users/drkaplan/.rvm/rubies/ruby-2.2.2/bin:/Users/drkaplan/.rvm/bin:/Users/drkaplan/.nvm/versions/node/v6.11.2/bin:/Users/drkaplan/google-cloud-sdk/bin:/Users/drkaplan/.rbenv/shims:/Users/drkaplan/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin:/Applications/Postgres.app/Contents/Versions/latest/bin: No such file or directory
Ideas for where to look next?
The solution in this case was to reinstall rails:
gem install rails

ERROR: Error CREATEing SolrCore 'hydra-development': Could not create a new core

I am trying to run solr_wrapper along with fc_wrapper to run my app.
This is how I am starting the solr,
enter code here
solr_wrapper -d solr/config/ --collection_name hydra-development --version 6.3.0
But when I hit this command, below is the error I am getting.
Failed to execute solr create: (RuntimeError)
Creating new core 'hydra-development' using command:
http://localhost:8983/solr/admin/cores?action=CREATE&name=hydra-development&instanceDir=hydra-development
I am able to start the fc_wrapper.
Can someone helpstarting the solr_wrapper.
These "solr_wrapper" and "fc_wrapper" tools do not come with Solr. Somebody else built those, so I have no idea how they work or what they do.
In order to create a core, the config must be available. See the big red box here:
https://cwiki.apache.org/confluence/display/solr/CoreAdmin+API#CoreAdminAPI-CREATE

Vim ruby, rails omnicompletion: "Error loading rails environment". How do I configure vim-ruby's autocomplete to work with rails?

I'm trying to get vim-ruby's autocompletion working with vim-rails. So far, I'm able to do local keyword completion with existing methods and variables in the current file, using <C-x><C-n> (although prefixes for instance variables and symbols are not preserved). I'd like to be able to autocomplete Rails methods like redirect_to and has_many. However, when I try to use omni-completion to accomplish this task, e.g. redir<C-x><C-o>, Vim tells me:
Error loading rails environment
Press ENTER or type command to continue
When I press ENTER, Vim tells me:
-- Omni completion (^O^N^P) Pattern not found
vim-ruby's autocompletion works for plain Ruby files, so that Arr<C-x><C-o> completes to Array, and in turn Array.<C-x><C-o> offers a list of methods on Array to choose from. When I try this in a Rails file, I get the same error as above; however, when I press ENTER to dismiss the error, ruby's autocompletion works as expected.
My question is, how do I properly configure vim-ruby so it can load the Rails environment? I assume that it's a vim-ruby problem and not vim-rails because commands like :Econtroller <controllername> work as expected.
My .vimrc contains the following:
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'flazz/vim-colorschemes'
Plugin 'slim-template/vim-slim'
Plugin 'vim-ruby/vim-ruby'
Plugin 'tpope/vim-rails'
Plugin 'tsaleh/vim-shoulda'
Plugin 'ervandew/supertab'
call vundle#end()
autocmd FileType ruby set omnifunc=rubycomplete#Complete
let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_classes_in_global = 1
let g:rubycomplete_rails = 1
Upon further investigation, vim-ruby was executing the system's ruby, with which I wasn't able to get rubygems to work. I'm not absolutely sure, but I believe vim-ruby/autoload/rubycomplete.vim was failing at this line while attempting to require the console_app gem, which didn't exist on my system.
So I re-built vim according to the instructions on Jon Cairns' blog. The article references RVM, but is equally applicable to rbenv or whatever ruby you might be using.
For posterity's sake, on Ubuntu, the steps I took to do this were:
sudo apt-get install mercurial
hg clone https://vim.googlecode.com/hg/ vim && cd vim
./configure --with-features=HUGE --enable-pythoninterp=yes --enable-multibyte=yes --enable-rubyinterp=yes --with-ruby-command=$(which ruby) --enable-gui=gnome2 --with-x --enable-fontset
make
sudo make install
After doing this, omni-completion in Rails works like a charm - albeit a bit slow the first time it's used.

Can not create rails apps anymore under Ubuntu

I have a problem with all my three! Ubuntu systems. I can't create any Rails projects anymore with the following command
rails new abcde
I get the following error message.
Can't initialize a new Rails application within the directory of another, please change to a non-Rails directory first
I know the error message is really clear, I googled and checked all the entries here on StackOverflow. No one had another explanation other than there is a project in a parent folder, which is not the case in my systems!
I checked all folders back to root for any hidden files resembling a rails project. Nothing! I even created a new folder under root /projects and tried to create a project in there, same error. I don't know what to do anymore, I have the same problem on all three of my Ubuntu computers. Has anyone ever had this problem and could fix it? What could be another cause of this. Because there is no project in any of parent folders.
The only possible solution for me is, that there is maybe a PATH variable for Rails that I don't know about and there is maybe a project in there?
SUGGESTIONS:
0) I'm assuming you're typing these commands from a console window, and not executing a shell script, shortcut, or "something else". Correct?
1) Please update your post with the following: ruby -v; rails -v (Ruby and Rails version info)
2) Please try another test project, and copy/paste any error or warning messages you see:
cd /tmp
rails new abc -f
<= another test "rails new", with "--force" option
3) Assuming you've installed RVM, and assuming your "rails new" is calling "run bundle install", then also make sure your user is a member of the "rvm" group:
sudo usermod -G rvm -a MYUSER
4) If you haven't already, please also look at these links:
can't initialize a new rails application within the directory of another
Problems with RVM and Rails when creating new app

Access to folders on Ubuntu-based Rails server (keep getting "No such file..")

I am setting up Rails+ffmpeg on Ubuntu and I keep getting
Errno::ENOENT
No such file or directory..
The setup is as follows:
/home/username/RailsApp
/home/username/videos/
I am trying to run ffmpeg to write to /home/username/videos and I used "/home/username/videos/" and "~/videos/" but no luck..
What am I missing?
"www-data" user is included in "username" group..
Rails app works fine otherwise..
Any input greatly appreciated!
Thanks!
Generally is good not to be dependent on local file system. Try following:
path_to_video = "#{Rails.root.to_s}/videos/video1.avi"
print File.exist?(path_to_video)
If you don't want to have videos in Rails/public just create a link with ln -s target link_name and on production server you should do it in similar way e.g. with capistrano.
Btw. what are the rights to videos? -rw-r--r--? and under wich user is running your webserver?

Resources