Rails 5 LoadError (cannot load such file -- roo) - ruby-on-rails

I cannot seem to load roo and want to use it to import google spreadsheets
Im using rails 5.2.3, ruby 2.6.1p33
roo (2.8.2, 2.7.1)
Does anyone have an idea why this is happening?
When I try requiring roo in irb console, it seems to be working
class User < ApplicationRecord
has_secure_password
validates :username, presence: true, uniqueness: true
require 'roo'
def self.import(file)
spreadsheet = Roo::Spreadsheet.open(file.path)
end
end
Gemfile
gem "roo", "~> 2.8.0"

It's mostly an issue with your spring loader, run
bundle exec spring stop
bundle exec spring start

Related

uninitialized constant Model::AlgoliaSearch

I have an issue including Algolia module in my rails app
I have included gem "algoliasearch-rails", ran bundle install and added in config/initializers an algoliasearch.rb file with api id and key
#model.rb
include AlgoliaSearch
algoliasearch do
attribute :name, :description, :content, :is_public => true
end
I think you should restart your rails server ;)

uninitialized constant Mongoid::Slug - can't get mongoid-slug to work

Receiving uninitialized constant Mongoid::Slug when trying to load a view.
The troubled Model is:
class Course
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::Slug
field :title, type: String
slug :title
validates :title, presence: true, uniqueness: true
end
Gemfile is pulling in mongoid and mongoid-slug as so:
gem 'mongoid', github: 'mongoid/mongoid', branch: 'master'
gem 'mongoid_search', '0.3.2'
gem 'mongoid-slug', github: 'digitalplaywright/mongoid-slug'
gem list shows the versions of each installed as:
mongoid (4.0.0)
mongoid-slug (4.0.0)
mongoid-tree (2.0.0)
mongoid_search (0.3.2)
Any suggestions as to what is occurring here?
All appears to have been resolved by restarting the dev environment.
Spun up the dev VM this morning and everything is happily playing along.
So perhaps after introducing mongoid-slug I should have just restarted the web server.

Trouble running httparty in rails 4.0 with ruby 2.0

To include httparty in my rails 4.0.0 app, in my gemfile I wrote:
gem 'httparty'
and then ran bundle install
Next in my application.rb file, I inserted this:
module myApp
class Application < Rails::Application
### ---
config.gem "httparty"
### ---
end
Now when I load rails c and do a require "httparty", I get false
What am I doing wrong? How do I load httparty in my rails app?
It's already loaded by Rails. You also don't need the config.gem in application.rb
Try using HTTParty from the console. It should just work.

Rails Gem::LoadError in UsersController#new

New to Ruby on Rails and having a problem when following Michael Hartl's tutorial.I'm using Rails 3.2.2 with Ruby 1.9.3. The issue looks very similar to another question that was raised but was unanswered:
Rails Error NoMethodError in UsersController#show error
I get the following error when attempting to add a new user via /signup
Gem::LoadError in UsersController#new
bcrypt-ruby is not part of the bundle. Add it to Gemfile.
Reloading the page gives the error:
NoMethodError in UsersController#new
undefined method `key?' for nil:NilClass
The problem seems to be related to the inclusion of the bcrypt-ruby gem, and the usage of the has_secure_password method in user.rb . Removing the call to has_secure_password in user.rb gets rid of the error and it goes to the signup page successfully.
user.rb:
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# name :string(255)
# email :string(255)
# created_at :datetime not null
# updated_at :datetime not null
# password_digest :string(255)
#
class User < ActiveRecord::Base
attr_accessible :name, :email, :password, :password_confirmation
has_secure_password
validates :name, presence: true, length: { maximum: 50 }
valid_email_regex = /\A[\w+\-.]+#[a-z\d\-.]+\.[a-z]+\z/i
validates :email, presence: true,
format: { with: valid_email_regex },
uniqueness: { case_sensitive: false }
validates :password, length: { minimum: 6}
end
users_controller.rb:
class UsersController < ApplicationController
def new
#user = User.new
end
def create
#user = User.new(params[:user])
if #user.save
flash[:success] = "Welcome!"
redirect_to #user
else
render 'new'
end
end
end
However, I cant find anything wrong with the inclusion of the bcrypt-ruby gem. In the Gemfile I have:
gem 'bcrypt-ruby', '3.0.1'
and the gem has also been generated in Gemfile.lock :
DEPENDENCIES
annotate (~> 2.4.1.beta)
bcrypt-ruby (= 3.0.1)
I've also added password_digest to the database via migration:
class AddPasswordDigestToUsers < ActiveRecord::Migration
def change
add_column :users, :password_digest, :string
end
end
Any ideas ?
I'm going through the same tutorial and encountered the exact same problem.
My solution was to restart the web server. After installing the gem, I think the web server needs to be restarted so it is loaded.
Justin
Did you tried the 'bundle update' command, usually the bundler will take care of gems if you specified in the Gemfile. If you want to check the gem dependency please check http://rubygems.org/gems.
And if you are using windows(I know its strange- but some of our app works in windows only) there is some tricks to install bcrypt
Steps to install bcrypt.
1 Download Devkit and extract
you can download it from here http://rubyinstaller.org/downloads/
2 Place devkit it your jruby folder (in my case C:\applications\jruby\devkit)
3 You need to install ruby as well either 1.8.7 or 1.9(some times needs a system restart)
4 CD into devkit directory
5 Run ruby dk.rb init
6 Open config.yml and make sure that both your jruby installtion is listed. If not, ADD them. Save and close config.yml after you're done.
example:- C:/applications/jruby
7 Run ruby dk.rb install
8 jruby -S gem install bcrypt-ruby
Restarting the web server fixed it for me (had spork running in the background to speed up the running of the tests)

using delayed_paperclip gem with delayed_job gem

i am working on a simple rails project and i use paperclip to upload attachments but when ever i use delayed job gem with delayed_paperclip gem i dont see the attachment. I followed the rdoc and tried it out but my guess is that i am not running delayed job well.
my attachment.rb lookes like this
has_attached_file :file
process_in_background :file
and i added this to my database
class AddFileProessingToAttachments < ActiveRecord::Migration
def change
add_column :attachments, :file_processing, :boolean
end
end
what else do i need to do again because i have waited for a long time and i still have a missing file.
I just realized that i have to start the delayed job task with the following command.
rake jobs:work
did not know until i checked my list of rake tasks

Resources