I am fairly new to rails and am chasing my tail trying to get a Rails app to run on my server. Locally on my Mac, everything is working fine, however when I run it on the Ubuntu server, I'm getting a NameError (uninitialized constant Api::V1::TestController::Headless)
error. I have updated bundler and the relevant gems as was suggested in other posts. I am certain that Headless is in my gem file, is up to date, and is install properly. I am using Headless in with Watir Webdriver. Any suggestions on what could be causing this error would be greatly appreciated.
Ruby Version: 2.2.3
The controller in question:
class Api::V1::TestController < ApplicationController
respond_to :json
def index
respond_with "test controller"
end
def create
event_submit(params[:json_event])
respond_to do |format|
if ( @log.present? )
format.json { render text: "Log: " + @log }
else
format.json { render text: "Error, no log" }
end
end
end
def nul_check(param)
param ||= "none"
return param
end
def event_submit(params)
@log = ""
#initialize the log
@log = ""
#set the browser that we will use to chrome for testing
#use headless
headless = Headless.new
headless.start
browser = Watir::browser.start 'www.google.com'
@log += browser.title
end
end
The Gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.4'
# Use postgresql as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
#Api gems
gem 'active_model_serializers'
gem 'deathbycaptcha'
gem 'rspec'
gem 'responders', '~> 2.0'
#Driver gems
gem 'watir-extensions-element-screenshot'
gem 'selenium-webdriver'
gem 'chromedriver-helper'
gem 'headless'
gem 'nokogiri'
gem 'watir-webdriver'
group :development, :test do
gem 'sqlite3'
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
gem 'unicorn'
The problem turned out to be server ownership. The user, rails in my case, did not have ownership of the gems since I had run bundle install
under my own account. A chmod
for the rails user took care of the problem!