undefined local variable or method `acts_as_gmappable' for gmaps4rails - ruby-on-rails-4

I am using gmaps4rails gem in my project for showing google maps on the forms but its showing
"undefined local variable or method `acts_as_gmappable' for gmaps4rails"
i am using rails 4.
gem 'gmaps4rails'
rails generate gmaps4rails:install
in model
acts_as_gmappable
def gmaps4rails_address
      address
end
Thanks,

im having the same issue as of 10/23/13
issue happens ONLY when deploy to Heroku; this works fine in my local environment
Gemfile contains:
...
gem 'rails', '4.0.0'
gem 'mysql'
gem 'haml'
gem 'paperclip'
gem 'gmaps4rails'
gem 'aws-s3'
gem 'aws-sdk'
gem 'stripe', :git => 'https://github.com/stripe/stripe-ruby'
gem 'will_paginate', '~> 3.0.5'
gem 'twilio-ruby'
gem 'json'
gem 'nokogiri'
gem 'rails_12factor', group: :production
...
already tried bundle install / bundle update & heroku restart
trace is as follows:
---> Preparing app for Rails asset pipeline
Running: rake assets:precompile
rake aborted!
undefined method acts_as_gmappable' for #<Class:0x007fa770b8ba68>
/tmp/build_94e76989-9e4f-4eef-8e2c-e31cd7d850c9/vendor/bundle/ruby/2.0.0/g ems/activerecord-4.0.0/lib/active_record/dynamic_matchers.rb:22:inmethod_missin g'
/tmp/build_94e76989-9e4f-4eef-8e2c-e31cd7d850c9/app/models/hay_shipper.rb: 4:in `'

Related

Bundler:GemNotFound error even though gem is locally installed

In my application, I am using a cron job to execute a simple model method.
A few gems were required for this task.
I installed a gem by including it in the gemfile and running the command
bundle install
Now when I run the server, I get the following error:
/home/aditya9509/.rvm/gems/ruby-1.9.3-p551/gems/bundler-1.10.5/lib/bundler/spec_set.rb:92:in `block in materialize': Could not find mime-types-data-3.2016.0221 in any of the sources (Bundler::GemNotFound)
from /home/aditya9509/.rvm/gems/ruby-1.9.3-p551/gems/bundler-1.10.5/lib/bundler/spec_set.rb:85:in `map!'
from /home/aditya9509/.rvm/gems/ruby-1.9.3-p551/gems/bundler-1.10.5/lib/bundler/spec_set.rb:85:in `materialize'
from /home/aditya9509/.rvm/gems/ruby-1.9.3-p551/gems/bundler-1.10.5/lib/bundler/definition.rb:140:in `specs'
from /home/aditya9509/.rvm/gems/ruby-1.9.3-p551/gems/bundler-1.10.5/lib/bundler/definition.rb:185:in `specs_for'
from /home/aditya9509/.rvm/gems/ruby-1.9.3-p551/gems/bundler-1.10.5/lib/bundler/definition.rb:174:in `requested_specs'
from /home/aditya9509/.rvm/gems/ruby-1.9.3-p551/gems/bundler-1.10.5/lib/bundler/environment.rb:18:in `requested_specs'
from /home/aditya9509/.rvm/gems/ruby-1.9.3-p551/gems/bundler-1.10.5/lib/bundler/runtime.rb:13:in `setup'
from /home/aditya9509/.rvm/gems/ruby-1.9.3-p551/gems/bundler-1.10.5/lib/bundler.rb:127:in `setup'
from /home/aditya9509/.rvm/gems/ruby-1.9.3-p551/gems/bundler-1.10.5/lib/bundler/setup.rb:18:in `<top (required)>'
from /home/aditya9509/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/aditya9509/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/aditya9509/Desktop/rubystack-2.0.0-33/projects/cricketStockExchange/config/boot.rb:3:in `<top (required)>'
from bin/rails:8:in `require_relative'
from bin/rails:8:in `<main>'
It says that the bundler was not able to locate mime-types-data-3.2016.0221 gem in any of the sources. To check, I ran the following command which gives a list of locally installed gems related to mime:
gem list | grep "mime"
This gave the following output:
mime-types (3.0, 2.99, 2.6.2)
mime-types-data (3.2016.0221)
Clearly the mime-types-data-3.2016.0221 is installed locally but bundler is not able to find it. Is there any fix to this. Below is my Gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.4'
# Use mysql as the database for Active Record
gem 'mysql2', '~> 0.3.18'
# 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'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# 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
gem 'whenever', :require => false
# Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.7'
gem 'mime-types-data','~> 3.2016.0221'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# 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
I am not sure as to what more information would be appropriate so let me know, I will update my question as needed.
Thanks!
Does the issue persist when running the server with bundle exec rails s?

No exception received from Rake task with Airbrake rails integration

Since version 5 Airbrake and its Rails integration offers automatic exception reporting in any Rake tasks.
However I've not received rake exception on my errbit server.
I've made the following test :
Create a fresh rails 4.1 application.
Include airbrake gem.
Create Airbrake initializer (used an errbit configuration).
Add a rake task which raises an exception.
Gemfile
source 'https://rubygems.org'
gem 'rails', '4.1.6'
gem 'sqlite3'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'spring', group: :development
gem 'airbrake', '5.0.5'
initializers/airbrake.rb
Airbrake.configure do |config|
config.environment = Rails.env
config.host = 'https://xxxxxxxxxx.herokuapp.com/'
config.project_id = true
config.project_key = 'xxxxxxxxxxx'
config.ignore_environments = []
end
lib/rake/raise.rake
namespace :raise do
desc 'raise error'
task error: :environment do
1 / 0
end
end
I tried to execute the rake task rake raise:error and got the following backtrace:
rake aborted!
ZeroDivisionError: divided by 0
/Users/Yann/code/airbraker/lib/tasks/raise.rake:4:in `/'
/Users/Yann/code/airbraker/lib/tasks/raise.rake:4:in `block (2 levels) in <top (required)>'
/Users/Yann/.gem/ruby/2.2.2/gems/airbrake-5.0.5/lib/airbrake/rake/task_ext.rb:19:in `execute'
Tasks: TOP => raise:error
(See full trace by running task with --trace)
And never received any exception on my errbit server.
Note: execute rake airbrake:test sends an exception to my errbit server, I assume my configuration is correct.
Am I missing something ?
This is a minor bug. The problem is that Airbrake tries to be asynchronous and sometimes it doesn't work as expected. In this particular case the Ruby process quits before Airbrake sends your exception.
I've submitted a patch, which should fix this issue: https://github.com/airbrake/airbrake/pull/513

How to deploy Rails App using private_pub to heroku

I am trying to run my app on heroku which is using private_pub gem . Here in my local server I am running it perfectly . How can I push this app in heroku and run there perfectly . Here is my gem file :
source 'https://rubygems.org'
gem 'rails', '4.2.1'
gem 'sass-rails', '5.0.2'
gem 'uglifier', '2.5.3'
gem 'coffee-rails', '4.1.0'
gem 'jquery-rails', '4.0.3'
gem 'turbolinks', '2.3.0'
gem 'jbuilder', '2.2.3'
gem 'bcrypt', '3.1.7'
gem 'mailboxer'
gem 'bootstrap-sass', '3.2.0.0'
gem 'sdoc', '0.4.0', group: :doc
gem 'devise'
gem 'paperclip', '~> 4.1'
gem 'will_paginate', '3.0.7'
gem 'bootstrap-will_paginate', '0.0.10'
gem 'faker', '1.4.2'
gem 'chosen-rails'
gem 'jquery-turbolinks'
gem 'private_pub'
gem "thin"
#gem 'puma', '2.11.1'
group :development, :test do
#gem 'sqlite3', '1.3.9'
gem 'mysql2'
#gem 'byebug', '3.4.0'
gem 'web-console', '2.0.0.beta3'
gem 'spring', '1.1.3'
gem 'byebug', '3.4.0'
end
group :test do
gem 'minitest-reporters', '1.0.5'
gem 'mini_backtrace', '0.1.3'
gem 'guard-minitest', '2.3.1'
end
group :production do
gem 'pg', '0.17.1'
gem 'rails_12factor', '0.0.2'
gem 'puma', '2.11.1'
end
And This is my private_pub.yml file :
development:
server: "http://localhost:9292/faye"
secret_token: "secret"
test:
server: "http://localhost:9292/faye"
secret_token: "secret"
production:
server: "https://sheltered-sea-1191.herokuapp.com/faye"
secret_token: "mysecret key"
signature_expiration: 3600 # one hour
How can I push this app in heroku help me to push this on herok .
For this above question I have created a new heroku app and I put this code as it is told in this tutorial https://webprogramming29.wordpress.com/2013/02/15/setup-privatepub-or-faye-on-heroku/
And then I edited my code using the following tutorial and it is working great

Rails 4 assets not loading in heroku after 'rake assets:precompile'

This is driving me insane! My app works properly on the local server, but when I uploaded to heroku, the css and js files didn't update. I read to precompile using rake assets:precompile to fix the issue, but then I uploaded to heroku again and now all my assets aren't loading at all! I've tried all variations of precompile, installed 12factor gem, turned some config settings from false to true, still not happening! When i look at the console, it says
[Error] ReferenceError: Can't find variable: jQuery
global code (application-38ccb09605964287831a37a0d9faf188.js, line 1)
but I do have Jquery! it works fine on local! I dunno what I'm doing wrong guys.
Gemfile
gem 'bootstrap-sass-rails'
gem 'rails_12factor', group: :production
gem 'rails', '4.0.0'
gem 'sqlite3', :group => [:development, :test]
group :production do
gem 'thin'
gem 'pg'
end
gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'jbuilder', '~> 1.2'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
production.rb
config.cache_classes = true
config.eager_load = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.serve_static_assets = true
config.assets.js_compressor = :uglifier
config.assets.compile = true
config.assets.digest = true
config.assets.version = '1.0'
config.log_level = :info
config.i18n.fallbacks = true
config.active_support.deprecation = :notify
config.log_formatter = ::Logger::Formatter.new
running $RAILS_ENV=production bundle exec rake assets:precompile made my heroku app work now. so i guess problem is fixed..
sorry, I don't have an explanation on why it works
Simply run
$ bundle exec rake assets:precompile
$ git add .
$ git commit -am "assets precompiled locally"
$ git push heroku master

Active admin in Rails 4 throws error "Invalid option key"

Rails 4 app working just fine until Active Admin is included (from this thread) in the gemfile.
My Gemfile:
gem 'rails', '4.0.0'
gem 'rails_12factor', group: :production
gem 'pg'
gem 'sass-rails', '~> 4.0.0.rc1'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'activeadmin', github: 'gregbell/active_admin'
gem 'protected_attributes'
gem 'rails-observers'
gem 'actionpack-page_caching'
gem 'actionpack-action_caching'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'
group :doc do
gem 'sdoc', require: false
end
The error is thrown while attempting to start the rails server after a clean bundle install.
/var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_controller/railtie.rb:55:in `block (3 levels) in <class:Railtie>': Invalid option key: page_cache_directory= (RuntimeError)
Any help is greatly appreciated!
Try to use:
http://blog.remarkablelabs.com/2012/12/russian-doll-caching-cache-digests-rails-4-countdown-to-2013
Or:
run bundle install and reinstall actionpack-action_caching
https://github.com/rails/actionpack-action_caching