I get the following error:
NoMethodError (undefined method `eager_load' for nil:NilClass)
when I run the following command in Mongoid 2.2.1
Person.includes(:game).all.each do
user.game.dosomething
end
a Person has_one Game
Just turn on Identity Map: http://mongoid.org/en/mongoid/docs/identity_map.html
Try add this to your Gemfile
# gem "mongoid-eager-loading"
But note that it's deprecated in newer mongoid versions
Related
Since the forum at akeneo.com is locked down, I posted my question here.
When I try to add Produkts to a Product-Model via mass-edit, I get the following error message:
No JobInstance found with code "add_to_existing_product_model"
[2018-06-19 19:39:31] request.INFO: Matched route "pim_enrich_mass_edit_rest_launch". {"route":"pim_enrich_mass_edit_rest_launch","route_parameters":{"_controller":"pim_enrich.controller.rest.mass_edit:launchAction","_route":"pim_enrich_mass_edit_rest_launch"},"request_uri":"http://pim.eu-trading.eu/rest/mass_edit/","method":"POST"} []
[2018-06-19 19:39:32] request.CRITICAL: Uncaught PHP Exception Symfony\Component\Translation\Exception\NotFoundResourceException: "No JobInstance found with code "add_to_existing_product_model"" at ./vendor/akeneo/pim-community-dev/src/Pim/Bundle/EnrichBundle/MassEditAction/OperationJobLauncher.php line 59 {"exception":"[object] (Symfony\\Component\\Translation\\Exception\\NotFoundResourceException(code: 0): No JobInstance found with code \"add_to_existing_product_model\" at ./vendor/akeneo/pim-community-dev/src/Pim/Bundle/EnrichBundle/MassEditAction/OperationJobLauncher.php:59)"} []
I get this error with the latest version of Akeneo 2 (v2.2.5). The product model was created manually, the products to be associated with the model came through the api.
This error looks like a missing job in the database. Did you run all the doctrine migrations?
To do so you need to launch this command:
bin/console doctrine:migrations:migrate --env=prod
If you already launched the migrations and they failed, you can install a clean 2.2.5 PIM elsewhere and dump the job instance table to be able to add the missing jobs. Here is the list of the jobs to add or update in 2.2:
- add_association
- move_to_category
- add_to_category
- remove_from_category
- add_to_existing_product_model
- compute_family_variant_structure_changes
- compute_completeness_of_products_family
- add_attribute_value
- delete_products_and_product_models
None of what used to work in RC.x helps anymore.
I have tried these:
PlatformServices.Default.Application.ApplicationVersion;
typeof(Controller).GetTypeInfo().Assembly.GetCustomAttribute<AssemblyFileVersionAttribute>().Version;
Assembly.GetEntryAssembly().GetName().Version.ToString();
They all return 1.0.0.0 instead of 1.0.0-9 which should be after execution of the dotnet publish --version-suffix 9 having this in project.json: "version": "1.0.0-*"
Basically they give me "File version" from the attached picture instead of "Product version" which dotnet publish actually seems to change.
For version 1.x:
Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
For version 2.0.0 this attribute contains something ugly:
2.0.0 built by: dlab-DDVSOWINAGE041 so use this one:
typeof(RuntimeEnvironment).GetTypeInfo().Assembly.GetCustomAttribute<AssemblyFileVersionAttribute>().Version;
I would do it like this on ASP.NET Core 2.0+
var assemblyVersion = typeof(Startup).Assembly.GetName().Version.ToString();
In .Net Core 3.1 I show the version directly in my View using:
#GetType().Assembly.GetName().Version.ToString()
This shows the Assembly Version you have in your csproj file:
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<FileVersion>2.2.2.2</FileVersion>
<Version>4.0.0-NetCoreRC</Version>
</PropertyGroup>
If you want to display the "other" FileVersion or "Informational" Version properties in the View add using System.Reflection:
using System.Reflection;
.... bunch of html and stuff
<footer class="main-footer">
<div class="float-right hidden-xs">
<b>Assembly Version</b> #(Assembly.GetEntryAssembly().GetName().Version)
<b>File Version</b> #(Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyFileVersionAttribute>().Version)
<b>Info Version</b> #(Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion)
</div>
</footer>
Note that after adding the System.Reflection the original #GetType().Assembly.GetName().Version.ToString() line returns 0.0.0.0 and you need to use the #Assembly.GetEntryAssembly().GetName().Version
There's a blog post here
Edit: Make sure to follow proper naming conventions for the Version strings. In general, they need to lead with a number. If you don't, your app will build but when you try to use NuGet to add or restore packages you'll get an error like 'anythingGoesVersion' is not a valid version string. Or a more cryptic error: Missing required property 'Name'. Input files: C:\Users....csproj.'
more here:
This work for me too:
#Microsoft.Extensions.PlatformAbstractions.PlatformServices.Default.Application.ApplicationVersion
It works with csproj file - either <Version>1.2.3.4, or <VersionPrefix>1.2.3</VersionPrefix>. However the <VersionSuffix> isn't recoganized as this doc says.
The answer by Michael G should have been the accepted one since it works as expected. Just citing the answer by Michael G above.
var version = GetType().Assembly.GetName().Version.ToString();
works fine. It gets the Package version set in the Package tab of project properties.
As an addition, if we need to get the Description we set in the same tab, this code would work. (core 3.1)
string desc = GetType().Assembly.GetCustomAttribute<AssemblyDescriptionAttribute>().Description;
Just in case someone needs this.
Happy coding !!!
Here are my gem list,
mongo (1.8.2)
mongoid (3.0.17)
mongoid-grid_fs (1.7.0)
carrierwave (0.8.0)
carrierwave-mongoid (0.4.0)
I have tried to generate an upload image but it dont work, the carrierwave.rb its looks like this:
require 'carrierwave/mongoid'
CarrierWave.configure do |config|
config.grid_fs_database = Mongoid::Config.sessions[:default]
config.grid_fs_port = 27017
config.grid_fs_host = '127.0.0.1'
config.storage = :grid_fs
end
but puts an error:
/config/initializers/carrierwave.rb:3:in `block in <top (required)>': undefined method `grid_fs_database=' for CarrierWave::Uploader::Base:Class (NoMethodError)
.....
there is a solution for that?
thanks
I took a quick look at the source for carrierwave-mongoid and it appears that the configuration options you specified (grid_fs_database, grid_fs_port, and grid_fs_host) are not valid options - hence your error.
My understanding is that carrierwave-mongoid derives its mongoDB configuration from the Mongoid configuration, so there's no need to specify this again. You configuration should look something like this:
require 'carrierwave/mongoid'
CarrierWave.configure do |config|
config.storage = :grid_fs
config.grid_fs_access_url = "/uploads" # or whatever you'd like the HTTP path to be
end
I am starting to write a MacRuby app. I installed some gems which i am interested in using. I get an error in xmlbase when trying to run.
/Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/builder-3.0.0/lib/builder/xmlbase.rb:in _indent': undefined method*' for nil:NilClass (NoMethodError)
I am using the 0.10 version of the framework. I downloaded the latest daily version to see if its been fixed but when my app runs its still calling the old 0.10 version. How do i get it to reference the newer version. Is this something in Xcode to something specific to MacRuby. Can i use RVM to do this?
Also anyone have any ideas if this has been fixed in a more recent version. The code i am using is as follows. You'll need a bet fair account to test!
require 'rubygems'
require 'betfairapi-savon'
class BetFairTest
def self.test
api = BetfairAPI.new
username = 'username'
password = 'pass'
response = api.login(username, password, 82, 0, 0, nil)
session_token = response.to_hash[:login_response][:result][:header][:session_token]
all_markets = api.get_all_markets(session_token,1)
api.keep_alive(session_token)
api.logout(session_token)
end
end
after the login i get the error
/Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/builder-3.0.0/lib/builder/xmlbase.rb:in `_indent': undefined method `*' for nil:NilClass (NoMethodError)
from /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/builder-3.0.0/lib/builder/xmlmarkup.rb:281:in `_special:'
from /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/builder-3.0.0/lib/builder/xmlmarkup.rb:254:in `instruct!:'
from /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/savon-0.9.7/lib/savon/soap/xml.rb:166:in `builder'
from /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/savon-0.9.7/lib/savon/soap/xml.rb:150:in `to_xml'
from /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/savon-0.9.7/lib/savon/soap/request.rb:38:in `setup:'
from /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/savon-0.9.7/lib/savon/soap/request.rb:23:in `initialize:'
from /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/savon-0.9.7/lib/savon/client.rb:79:in `request:'
from /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/betfairapi-savon-1.0.1/lib/betfairapi-savon.rb:17:in `login:'
from /Users/barry/Library/Developer/Xcode/DerivedData/TestApp-djtngswdhcnqvgdwihommmloripf/Build/Products/Debug/TestApp/Contents/Resources/BetFairTest.rb:20:in `test'
Cheers,
Barry.
I'm trying to port a Rails2 application over to Rails3 - this app provides a front-end to multiple databases, one of which is SQL Server 2005. The SQL Server 2005 database is legacy so I have to use set_table_name and set_primary_key as such:
class Project < ActiveRecord::Base
set_table_name "SpiraTest.TST_PROJECT"
set_primary_key "PROJECT_ID"
end
Firing up the console I can see
irb(main):002:0> Project.primary_key
=> "PROJECT_ID"
irb(main):003:0> Project.table_name
=> "SpiraTest.TST_PROJECT"
irb(main):004:0>
I can even use Project.find(:first), Project.find(:last), etc. and retrieve the data. What I can't do is find using an id, like this: Project.find(1). I get met with:
NoMethodError: undefined method `eq' for nil:NilClass
from /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active_support/whiny_nil.rb:48:in `method_missing'
from /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.9/lib/active_record/relation/finder_methods.rb:317:in `find_one'
from /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.9/lib/active_record/relation/finder_methods.rb:292:in `find_with_ids'
from /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.9/lib/active_record/relation/finder_methods.rb:107:in `find'
from /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.9/lib/active_record/base.rb:444:in `__send__'
from /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.9/lib/active_record/base.rb:444:in `find'
from (irb):4
irb(main):005:0>
I have been looking down through the finder_methods and can see where in the find_one method that
record = where(primary_key.eq(id)).first
'primary_key' is nil.
I'm at a loss on this - I'll continue to hunt and see what I find.
Gems being used for completeness:
gem 'rails', '3.0.9'
gem 'mysql2', '< 0.3'
gem 'activerecord-sqlserver-adapter'
gem 'mongrel'
gem 'psrutil'
gem 'net-ldap'
gem 'spreadsheet'
gem 'ruby-odbc'
Make sure to use set_primary_key and note, it is case sensitive.