pry raise an error using show-models with neo4j - neo4j

I just switched rails console to use pry.
I'm also using ruby 2.1.2p95, rails 4.1.5, neo4j (3.0.0.alpha.11), neo4j-community (2.1.3), neo4j-core (3.0.0.alpha.19)
While executing the command show-models it failed, returning the following error:
[3] pry(main)> show-models
ArgumentError: wrong number of arguments (1 for 2..3)
from /home/pdipietro/.rvm/gems/ruby-2.1.2/bundler/gems/neo4j-2e41203410cc/lib/neo4j/active_node/has_n.rb:79:in `has_one'
has anyone an idea on how to circunvent it?
Thank you
Paolo

Look in your models, one of them has a bad has_one call. Every has_one requires at minimum two parameters: a direction and an association name. That indicates you have one that's probably using the old syntax, just doing has_one :association. See documentation at https://github.com/neo4jrb/neo4j/wiki/Neo4j-v3-Declared-Relationships.
EDIT: Unfortunately, I just tested and it doesn't look like show-models doesn't recognize these models. You can add an issue at https://github.com/neo4jrb/neo4j and we can work on adding support. The error you're reporting still has nothing to do with pry, though.
Also, 3.0.0.alpha.11 is quite old at this point, the gem has been released and is now up to 3.0.1. You should really update.

Related

What do the numbers represent in an AssociationTypeMismatch error?

I got the following while attempting an assignment using the Rails console.
ActiveRecord::AssociationTypeMismatch: PurchaseOrder(#70303731156560) expected, got PurchaseOrder(#70303775861760)
What does #70303731156560 and #70303775861760 represent?
When ActiveRecord::AssociationTypeMismatch error occurs, those numbers after the class names refer to the different versions of the class. This error occurs when two different versions of the model have been loaded.
To solve this problem, you could use reload! in the console. Or, re-starting the console should fix it.

Conflict between Rails Admin and Impressionist gems

I'm using the latest version of the Impressionist and Rails Admin gems, and wondering if anyone could shed some light on an annoying conflict I'm experiencing. The problem is roughly documented here - https://github.com/sferik/rails_admin/issues/1315, yet the vaguely described solution is not working for me. When I have the line is_impressionable in my Listing model, I get an error when starting my Rails server with rails s:
...rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.2/lib/active_record/dynamic_matchers.rb:22:in `method_missing': undefined local variable or method `is_impressionable' for Listing(no database connection):Class (NameError)
If I first start the server, and then add the 'is_impressionable' line, everything works fine, so the problem only occurs during initialization. I don't fully understand the initialization process, so am not sure how to go about getting this to work.
I have tried moving all my rails_admin model configuration options to their respective models, rather than in the initializer, which had no effect. I also have the following line in my initializer:
config.included_models = [Listing,ListingImage,AllOtherModelsHere...]
I have tried adding single quotes around these model names, which results in the following errors, as described in the github issue here
[RailsAdmin] Could not load model Listing, assuming model is non existing. (undefined local variable or method `is_impressionable' for Listing(no database connection):Class)
Any ideas what else I can try to make these gems work together? I don't want to have to remove the is_impressionable line every time I want to restart the server or generate a migration...
Not sure if the same issue that I had but yet I will post what worked for me just in case someone struggles with this too:
Im on a ruby 2.1.5 project with rails 4.2.0 and among other gems I'm using rails admin.
I run into several weird problems trying to set this up. For instance if I added the is_impressionable call within one of my models for some reason the execution of that file stopped there and I started getting weird errors like any method declared below the is_impressionable failed with undefined error.
So what I end up doing was:
class MyModel < ActiveRecord::Base
include Impressionist::IsImpressionable
is_impressionable
end
So this solved my issue and now i can access #my_model_instance.impression_count as expected.
I changed every occurrence of Klass to 'Klass'.constantize in initializer.

SslRequirement.disable_ssl_check error undefined method?

I am working on an established project, Rails 3, and trying to turn of SSL in development. The following line in environments/development.rb generates an error.
config.after_initialize do
SslRequirement.disable_ssl_check = true
end
Error reads:
undefined method `disable_ssl_check=' for SslRequirement:Module (NoMethodError)
Any pointers to this?
Searches have revealed little so far.
Thank you
Based on the version number you provided (0.1.0) the problem is likely caused by the fact that you are using a different gem.
The one you use is ssl_requirement (repo), whereas the disable_ssl_check method is provided by bartt-ssl_requirement (repo). The latter one is actually a fork of the former one so you might try to upgrade.

Using mongomapper to execute server runCommand geoNear

I would very much like to use the mongo geoNear command as discussed here.
Here is the command I entered in my rails console with the accompanying error message.
MongoMapper.database.command({ 'geoNear' => "trips", 'near' => [45,45]})
Mongo::OperationFailure: Database command 'geoNear' failed:
(errmsg: 'more than 1 geo indexes :('; ok: '0.0').
I can not make sense of the error message, it is supposedly impossible to have more than 1 geo index and I am certain that I have only created one.
Based on this stackoverflow question I believe I am wording the query correctly. Does anyone understand that error message? How would I go about destroying and recreating my indexes?
I am using rails 3.1 with mongodb v2.0 and the mongo ruby gem v1.5.1.
I really asked this too soon, maybe I should delete it? Somehow there were in fact too many geo indexes, because deleting the index and recreating it fixed the problem.
MongoMapper.database.collection('trips').drop_indexes
Trip.ensure_index [[:route, '2d']]

"can't dump File" during "Rails.cache.fetch" and "Rails.cache.write"

I been working on porting my application on "Rails 3.0.7" ,ever since I started to employ caching for my application either (file cache,memcache or any other) . I always happen to get the above error "can't dump File" .
I Google a bit and found that it has something to do with Marshal dump as ruby interpreter does allow Marshal dump of object that have Procs or lambdas in them so I looked upon my code but I could not find any Proc and lambda in my whole applications
Now to discover the problem I drill down the ActiveRecord 3.0.7 code and here are few interesting finding that I came up with
1 . "includes" in Rails 3 + internally call the define name scope OK this I give the answer that there is Proc and Lambada associated with the object so the error but this doesn't explain why the same code work sometime and report with errors(above errors) other times I mean If the error is for the Marshalling and object that hold a Proc or a Lambada then code should definitely not work and should always report errors no matter how many times the same code is ran but that not the case over here the code return errors sometimes and work well other times
Code
Rails.cache.fetch("accessible_websites_1")
{ Website.includes(:account) }
2 . If the ".includes" in Rails 3.0 + has problem then what up with other 'include' syntax does it too report error (above error)
so I ran the code with older syntax of include
Here is it
Rails.cache.fetch("accessible_websites_1")
{ Website.all(:include =>
:account) }
well surprisingly it ran but it never preloaded the account related for all the website ( which is where weird) but at least It never gave and error
so did a forensic on Active Record 3.0 + once again to discover how the older version of include(Rails 2.3 +) work surprise to know that the older version of include syntax internally call the .includes method of ActiveRecord 3.0 +
whoo How is that possible
two different syntax both call the same internal method one report with error sometimes ( not every time but preload the associated object) and other does not report with error but neither preload the associated object as said earlier.
OK , Hearing all this if anyone can help me out then I would be utmost grateful
By the way
Here what I'm trying to achieve
Rails.cache.fetch("accessible_websites_1")
{ Website.includes(:account) }
the equivalent code of above in Rails 2.3.5 and Rails 3 + (but does not preload the associated account object of all websites)
i.e
Rails.cache.fetch("accessible_websites_1")
{ Website.find(:all,:include =>
:account) }
Work perfectly fine without any issue
I using
Ruby = "ruby 1.8.7 (2010-01-10
patchlevel 249) [i486-linux]" Rails
= " Rails 3.0.7"
The same Problem even persisted on Rails 3.1.0
am I missing something
I can also provide the model structure if required
The problem is that
Website.includes(:account)
does not load the data, it just provides you with a proxy object that will load the objects on demand when you do something like calling #each or #to_s, if you force the fetching by adding a #to_aat the end it should work, e.g. try
Marshal.dump(Website.includes(:account))
Marshal.dump(Website.includes(:account).to_a)
#all(x=>y) does not do the same thing as #x(y), that is why you can do X.includes.joins.where but not X.all.where.
Not sure where the reference to a File comes from though.

Resources