before_save :balance_status, :on => :update
it is throwing "Unknown key: :on. Valid keys are: :if, :unless, :prepend"
in Rails-6
before_save is used for both create and update. You should use before_update :balance_status instead.
In rails 6 the option on does not exists for before_save, see the official documentation for more info. You can use before_commit.
Related
I am working with WooCommerce for the first time and I am currently implementing WC filters on the shop page. The filters show up but are not functional, and the console is throwing the following errors:
ERROR 1: woocommerce_shared_settings filter in Blocks is deprecated. See https://github.com/woocommerce/woocommerce-gutenberg-products-block/blob/trunk/docs/contributors/block-assets.md
ERROR 2: deprecated.min.js?ver=932d8bb37da8bbb396a7a3f754345e08:2 select control in #wordpress/data-controls is deprecated since version 5.7. Please use built-in resolveSelect control in #wordpress/data instead.
The errors disappear when I remove the filters.
I have located the file where the deprecated code exists. I also read the WC docs about how to fix the issue and it presented this code:
use Automattic\WooCommerce\Blocks\Package;
use Automattic\WooCommerce\Blocks\Assets\AssetDataRegistry;
Package::container()->get( AssetDataRegistry::class )->add( $key, $value )
It doesn't say where to put this code, though. Where should I put it to solve this issue?
I have the same problem.
Which is the file you located?
Here also says you have to add, on the "client side", this code:
wc.wcSettings.getSetting( 'key' );
I'm working on a Symfony 3.4.6 app, that has a lot of YAML configuration files in the [project root]/config/packages. I added a key to one of them (let's say xyz.yaml):
xyz:
...
foo:
bar: 123
buz: 567
Now I'm getting an error:
In ArrayNode.php line 319:
Unrecognized option "foo" under "xyz"
I took a look into the ArrayNode.php#319. Well, the thing is clear: arbitrary / additional keys are not allowed. There seems to be something like a whitelist. But where is it defined / how to extend it (add the new keys to it)?
How to solve the "unrecognized option" issue by adding keys to Symfony configs?
I am working on a project with a 'database first' approach rest API backend. I am using ASP .Net Core 3.1 and Entity Framework 3.1.1.
I ran a script to scaffold the database into the models and db context class. However, some of the model building functions have tables/models without keys x.hasnokey(). I thought this would be fine but I get an error trying to hit the endpoint that states
ERROR : InvalidOperationException:
The navigation '' cannot be added because it targets the keyless entity type 'AAA'
Navigations can only target entity types with keys
This happens in a few different locations and this originally ran okay in the past. This is running on SQL Server 2012 (version 11). I am not sure how I can solve this issue, I have limited entity/sql experience and I just don't know where to begin. Here is the offending lines (inside DB Context):
modelBuilder.Entity<AAA>(entity =>
{
entity.HasNoKey();
entity.ToTable("BBB_AAA");
entity.HasOne(d => d.BBB)
.WithMany(p => p.AAA)
.HasForeignKey(d => d.CCC)
.OnDelete(DeleteBehavior.ClientSetNull)
...
}
The script I used to scaffold the models and db context was (generic version):
PM> Scaffold-DbContext "Server=.\SQLExpress;Database=SchoolDB;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
I believe this might be that the database that was originally created about 10-15 years ago, cannot be made into an ORM so easily as I would have hoped. It could also a versioning issue, the scaffolding script I ran is incorrect, or if I just am out of my depth but I would appreciate being pointed in the right direction. Thank you!
This error usually comes because of Primary Key issue.
In my Case I was running this query and result was same problem you mentioned
var exists = await _dbDontext.Students.FindAsync(Id);
My Student table has relations with other tables and one of other tables was missing Primary Key.
So two Possible Solutions .
Solution 1 :
Make Primary Key column in your table that is mentioned in your error.
Solution 2 :
If things are complicated , just delete the table and Re Create It. It would work fine
I think you have two options,
1- Go and add key to the table.
2- check the following link
https://learn.microsoft.com/en-us/ef/core/modeling/keyless-entity-types
Thanks
I am using the DataMapper gem with Sinatra and followed the tutorial here:
http://net.tutsplus.com/tutorials/ruby/ruby-for-newbies-working-with-datamapper/
I am connecting to the database and migrating as such:
DataMapper.setup :default, "sqlite://#{Dir.pwd}/ex2.db"
DataMapper.auto_migrate!
My data model:
class User
include DataMapper::Resource
property :id , Serial
property :username , String
property :email , String
end
I am executing using this command:
rackup config.ru
However, when I get to this line:
User.create username: "JoeSchmo", email: "joe#schmo.com"
I receive the error:
Rack::Lint::LintError: Status must be >=100 seen as integer
Any idea why this is happening?
Try deleting the SQLite DB - there seems to be a bug in data_mapper with changing the data structure and using old data. For me the bug went away after deleting the db and setting up a new one.
What version of ruby are you on because if you are on less than 1.9 you have to use the => hash constructor not : and move the colon to the beginning because it is a symbol.
User.create :username => "JoeSchmo", :email => "joe#schmo.com"
I had the same problem with Sinatra and datamapper. Creating my records with "new" keyword rather than "create" and then adding attributes one by one worked for me. Hope you find it useful.
I want to create a single named argument/option for symfony command. And want symfony to distinguish those 3 options:
my:command, which means something like my:command --arg=null
my:command --arg, which means my:command --arg=defalutValue
my:command --arg=someValue, which is fully explicit.
I.e. I want two working modes for code under that command: default one and non-default with additional argument, and that arg should have default value.
I understand, that I could create 2 args, but I'm looking for one-arg-to-rule-them-all solution.
Is it possible to accomplish that with built-in classes or should I create custom ones? If solution is only available with custom classes, please tell me, where to start (i.e. "create subclass of ..." or "install a bundle named ..."), cause I'm not familiar with Symfony2's architecture.
It is possible:
->addOption('arg', 'a', InputOption::VALUE_NONE)
my:command => $input->getOption('arg') //false
my:command --arg => $input->getOption('arg') //true
my:command --arg=5 => $input->getOption('arg') //5
Answer by corvax is incorrect and doesn't work. As of today, you just cannot achieve this.
It is even stated in the Console documentation: Using Command Options.
See also these issues on GitHub:
#8135 [Console] Input options with InputOption::VALUE_OPTIONAL and InputOption::VALUE_NONE not working as expected
#11883 [Console] Added three state long option
#12769 [Console] Ability to use option default only if the option was passed
#12773 [Console] Add method to know parsed option
Symfony2 have console component which can be used separately. You can see documentation here. For more example you can check implementations of SensioGeneratorBundle.