undefined method `acts_as_mappable' trying to use geokit - ruby-on-rails-3

I am trying to use geokit but I get the following message:
undefined method `acts_as_mappable'
I have tried the following solutions but nothing has worked so far:
Rails 3.1.0, geokit, with error acts_as_mappable
I am using rails 3.0.1 and ruby 1.9.2
I have followed the instructions here https://github.com/jlecour/geokit-rails3 but its not working
This is my model:
class Event < ActiveRecord::Base
acts_as_mappable :default_units => :kms,
:default_formula => :flat
end
and I have this in my gemfile
gem 'geokit-rails3'
I also have the folder vendor, inside I have a geokit-rails3 folder with the files, one of them named acts_as_mappable. I have tried adding require 'geokit-rails3' in the top of my model but it says no file to load.
I tried both, installing it as a plugin:
rails plugin install git://github.com/jlecour/geokit-rails3.git
and also by doing gem install (and it is shown when I list all the gems installed)
Any help is greatly appreciated.

The problem was solved by reinstalling rails with:
sudo apt-get install rails rails-doc rails-ruby1.8

Related

Rails 4.0 & Devise - Strong Parameters error

Newbie to rails here, so bear with me.
New app on Rails 4 with ruby 2.0, I installed Devise and followed the instructions(default root, etc). Devise readme on github says it should be compatible with rails4 but
db:migrate failed unless I commented out attr_accessible line in User.rb
After commenting that out, I get "ActiveModel::ForbiddenAttributesError in Devise::RegistrationsController#create" error in trying to create a user.
I see some stack overflow questions like this, but a lot of the answers jump straight into some complex talk. I get I need to specify permitted attributes for mass assignment, but how? And where? And which attributes need to be permitted, all of them? Only those that I expect to be changed/created at the same time?
Judging by the error would I create a registrations_controller.rb that inherits from Devise::registrationsController ? What do I specify in that?
Any step by step, newbie friendly answers are much appreciated. I've exhausted myself trying different code from answers here and various sites from google searches.
Welcome to stackoverflow!
The problem is that the functinality of attr_accessible changed in rails 4.0
2 possibilities to get it running
1 Update Devise that it can handle Rails 4.0
Add this line to your application's Gemfile:
gem 'devise', '3.0.0.rc'
And then execute:
$ bundle
2 Add the old functionality of attr_accessible again to rails 4.0
Try to use attr_accessible and dont comment this out.
Add this line to your application's Gemfile:
gem 'protected_attributes'
And then execute:
$ bundle
Adding below gems and doing a bundle install worked for me
source 'https://rubygems.org'
gem 'rails', '4.0.2'
gem 'bootstrap-sass', '2.3.2.0'
gem 'devise', '3.0.0.rc'
gem 'protected_attributes'
gem 'sqlite3'

rails 3 - LoadError (cannot load such file -- zip/zip)

I'm using rubyzip to zip a csv file so uses can download it. This works perfectly in development mode. But when I tried zipping the file on the production server (rackspace) I received the error: LoadError (cannot load such file -- zip/zip). Is it a path issue? Anyone know a fix?
The error is being called in my code on this line: require 'zip/zip'
I've tried the solution from here, but it didn't help.
I fixed this problem by specifying gem version 0.9.9 in Gemfile:
gem 'rubyzip', "~> 0.9.9"
Using rubyzip (1.0.0) caused an error.
When upgrading rubyzip to 1.0.0 change require 'zip/zip' to require 'zip'.
I had this problem after adding roo to a Rails project.
Roo needed the new interface, something else (some other gem) was using the old interface - so most of these answers didn't work (couldn't lower the version of rubyzip, rubyzip2 is deprecated, didn't have require zip/zip in my project).
What worked for me was cassio-s-cabral's answer referring to the rubyzip github page.
gem 'rubyzip', '>= 1.0.0' # will load new rubyzip version
gem 'zip-zip' # will load compatibility for old rubyzip API.
I had the same problem: error thrown on "require 'zip/zip'" code, and the solution from this post also did not help.
After a long research I found that the problem was that my "require 'zip/zip'" statement was done in a separate
lib/exporters/package_exporter.rb
file, and for some reason "require" statements are not handled in "lib" folder in production by default.
When I moved "require 'zip/zip'" to the beginning of my
app/controllers/packages_controller.rb
the problem was solved!
I had a similar issue with active_support, just added the 'zip' gem to my Gemfile and it worked fine
I'm use rubyzip2 gem to fix this problem
gem 'rubyzip2'
what work for me was to install 2 gems:
gem install rubyzip
gem install zip
and in the script put
require 'rubygems'
require 'zip/zip'
In their github page explains what to do.
Rubyzip interface changed!!! No need to do require "zip/zip" and Zip
prefix in class names removed.
If you have issues with any third-party gems what required old
version of rubyzip you can use next workaround:
gem 'rubyzip', '>= 1.0.0' # will load new rubyzip version
gem 'zip-zip' # will load compatibility for old rubyzip API.

acts_as_commentable_with_threading uninitialized constant Post::Comment Rails 3.1.3

I have upgraded my application from Rails 2.3.5 to Rails 3.1.3. I had acts_as_commentable_with_threading and awesome_nested_set as plugins. Now I have added in GemFile for Rails 3.1.3 as below
gem 'awesome_nested_set'
gem 'acts_as_commentable_with_threading'
I have code in the model as below
class Post < ActiveRecord::Base
acts_as_commentable
end
The migration for acts_as_commentable_with_threading is already applied in the database.
I have statement in the view as
<%= pluralize(post.root_comments.size, "comment") %> on this post
When I try to load that view I get error at that line as
uninitialized constant Post::Comment
What can be the problem. Please help me.
Thanks in advance!
You might have forgot to run the generator and the migration afterwards:
rails generate acts_as_commentable_with_threading_migration
or
rails generate acts_as_commentable_upgrade_migration
and after:
bin/rake db:migrate
It's first steps of github repo instructions

Delayed_job(2.1.4) + Rails(3.0.10) undefined method `delay'

I upgrading a rails application to rails(3.0.10) and update the gem delayed_job. I updated my migration for the table delayed_job but unfortunatly the method ".delay" doesn't work.
NoMethodError: undefined method `delay' for #<User:0x10394d140>
I didn't find a solution for that. I did : "bundle install", I restarted the server, tried to instal as plugin...
Do you have any ideas?
Thanks.
UPDATE :
I fixed the problem but created a file config/initializer/delayed_job.rb with
require 'delayed_job'
Delayed::Worker.backend = :active_record
Sometimes gems just refuse to install properly. I think what you should do is (assuming you have git installed, otherwise go here https://github.com/tobi/delayed_job and download delayed_job as a zip file)
git clone https://github.com/tobi/delayed_job.git
take what he has in his lib folder and put it in yours. wherever you need to use his methods then do
require 'delayed_job'
in the top of those files
I checked this tutorial, it shows a way to setup in rails 3
http://www.dixis.com/?p=335
it suggests using this in your gemfile
gem "delayed_job", :git => 'git://github.com/collectiveidea/delayed_job.git'
(if it doesn't work with this either, then try the same thing that i did, but replace
git clone https://github.com/tobi/delayed_job.git
with
git clone https://github.com/collectiveidea/delayed_job.git
tell me if anything works

no such file to load -- google_chart using gem gchartrb

I am trying to use the gem gchartrb to create some graphs/charts in my RoR application.
I have looked into several tutorial and all say the same thing, that I have to add
require 'google_chart'
But I am getting the message:
no such file to load -- google_chart
I have the require inside my controller, I have confirmed that the gem is installed.
I am using Rails 3.
Also, I have tried adding config.gem 'gchartrb', :lib => 'google_chart' in my environment.rb as suggested here but nothing changed
Thanks for your help
EDIT:
I have also tried with the gem googlecharts, what I have in my Gemfile is:
gem "googlecharts", :require => "gchart"
but I get no such file to load -- gchart when I try to load the view.
I am not sure, it is required now or not. But it worked for me in Rails 3 as well. I am using Rails 3.0.10. I added below 2 lines and it worked for me.
1) gem 'gchartrb' in Gemfile
2) require 'google_chart' in config/boot.rb
Hope it helps!
config.gem is for rails 2.3.X.
For rails 3, you will need to add the gem to your Gemfile and run gem bundle
You may also need to check that the google_charts gem actually supports Rails 3...
Given that the latest code update seems to have been in 2008 - that might not actually be likely. :(
You can try it anyway and see...