Less::ParseError: Cannot call method 'split' of undefined - Rails 4.0 - ruby-on-rails-4

Note: ruby 2.0.0p481, Rails 4.0.13
Execute : RAILS_ENV=development bundle exec rake assets:precompile
Trace:
DEPRECATION WARNING: Support for Rails < 4.1.0 will be dropped.
(called from at
/host_share/project/config/application.rb:9) rake aborted!
Less::ParseError: Cannot call method 'split' of undefined (in
/host_share/project/app/assets/stylesheets/main.css.less) at
/home/vagrant/.rvm/gems/ruby-2.0.0-p481/gems/less-2.6.0/lib/less/js/lib/less/parser.js:604:31
/home/vagrant/.rvm/gems/ruby-2.0.0-p481/gems/less-2.6.0/lib/less/parser.rb:100:in
`block in to_css'
I dont know whats wrong ... please help me..

The error is quite clear here: In your app/assets/stylesheets/main.css.less you are doing a .split() operation on an undefined object, hence this is raising an error. Go in that file, search for the .split() method and check why the object you are calling this method on is not defined.

Go to your app/assets/stylesheets/main.css.less search for split. Remove split from the file and inspect the object you're calling split on to see if it's not nill

Related

Mass assignment in Rails 5

I tried to upgrade Mindapp Gem from Rails 4 to Rails 5. There are a lots of codes like below need to be fixed because Rails 5.1 no longer support mass assignment to_bson directly.
Mindapp::Xmain.create :service=>service,
:start=>Time.now,
:name=>service.name,
:ip=> get_ip,
:status=>'I', # init
:user=>current_user,
:xvars=> {
:service_id=>service.id, :p=>params,
:id=>params[:id],
:user_id=>current_user.try(:id),
:custom_controller=>custom_controller,
:host=>request.host,
:referer=>request.env['HTTP_REFERER']
}
Then error:
DEPRECATION WARNING: Method to_bson is deprecated and will be removed in Rails 5.1, as `ActionController::Parameters` no longer inherits from hash. Using this deprecated behavior exposes potential security problems. If you continue to use this method you may be creating a security vulnerability in your app that can be exploited. Instead, consider using one of these documented methods which are not deprecated: http://api.rubyonrails.org/v5.0.2/classes/ActionController/Parameters.html
To comply with Rails 5.1 from this WARNING: I put params (without understand really) to:
Mindapp::Xmain.create(xmain_params)
def xmain_params
params.permit(
:service=>service,
:start=>Time.now,
:name=>service.name,
:ip=> get_ip,
:status=>'I', # init
:user=>current_user,
:xvars=> {
:service_id=>service.id, :p=>params,
:id=>params[:id],
:user_id=>current_user.try(:id),
:custom_controller=>custom_controller,
:host=>request.host,
:referer=>request.env['HTTP_REFERER']
}
)
end
Problem: It's not create as supposed to do.
This code (before modified) work in rails 4 but Warning in 5.0 and Now not work in Rails 5.1 all using Ruby 2.4.1.
What should I do/Thanks
And when tried
Mindapp::Xmain.create :service=>params.permit(service),
:start=>params.permit(Time.now),
:name=>params.permit(service.name),
:ip=>params.permit(get_ip),
:status=>params.permit('I'), # init
:user=>params.permit(current_user),
:xvars=> params.permit({
:service_id=>service.id, :p=>params,
:id=>params[:id],
:user_id=>current_user.try(:id),
:custom_controller=>custom_controller,
:host=>request.host,
:referer=>request.env['HTTP_REFERER']
})
Errors:
Mongoid::Errors::InvalidValue -
message:
Value of type ActionController::Parameters cannot be written to a field of type Hash
summary:
Tried to set a value of type ActionController::Parameters to a field of type Hash
resolution:
Verify if the value to be set correspond to field definition:
And try using params.
Mindapp::Xmain.create :service=>params.service,
:start=>params.Time.now,
:name=>params.service.name,
:ip=> params.get_ip,
:status=>params('I'), # init
:user=>params.current_user,
:xvars=> {
:service_id=>params.service.id, :p=>params,
:id=>params[:id],
:user_id=>params.current_user.try(:id),
:custom_controller=>params.custom_controller,
:host=>params.request.host,
:referer=>params.request.env['HTTP_REFERER']
}
Errors:
NoMethodError - undefined method `service' for #<ActionController::Parameters:0x007ff6b07158f0>:
actionpack (5.0.2) lib/action_controller/metal/strong_parameters.rb:646:in `method_missing'
app/controllers/mindapp_controller.rb:384:in `create_xmain'
The issue is :p=>params. I'm assuming params is a params object from the request. Under Rails 5.1, it will no longer support standard hash functions such as to_bson, which mindapp library appears to be using (or maybe one of its dependent libraries is using it).
A simple fix is probably to replace it with :p=>params.to_unsafe_hash or for a safer solution, :p=>params.permit(:foo, :bar) (whatever params should be used, these should possibly be checked/cleansed first).

Setting QT_DEBUG_PLUGINS fails

I have read this blogpost http://www.ics.com/blog/qt-tips-and-tricks-part-1 and tried to enable plugin debugging as described.
I've put this line in my main.cpp:
qputenv(QT_DEBUG_PLUGINS, 1);
But if I try to compile I'm getting this error:
.../src/main.cpp:14: error: 'QT_DEBUG_PLUGINS' was not declared in this scope
qputenv(QT_DEBUG_PLUGINS, -1);
What is the problem here and how do I have to do it right?
qputenv("QT_DEBUG_PLUGINS", QByteArray("1"));
But I don't get any additional output.
I'm using Qt5.5.1 with QtCreator 3.6 under KUbuntu 15.10.
You're supposed to set env variable from outside your program, not from inside! It's very likely the plugin loading you're interested into already happened by the time you reach that line. Try putting it before creating a Q*Application object.
– peppe
That's it. It was definitely set before plugin loading, but it seems to be important to set it before creating Q*Application as you wrote. Thank you.
– avb

Ruby require wrong argument type error

I implement ruby extension in c++. it compiled. but when i require module which i implement in my ruby test, it show an error. i create similar small module and require it same way in ruby code. it work fine. i can't figure out what is the problem. please help me.
thank you.
here is my code.
extconf.rb
require 'mkmf';
have_library( 'stdc++' );
$CFLAGS << " -Wall";
create_makefile( 'Graph' );
Rgraph.cpp
/*relevant methods here*/
extern "C" void Init_Graph(){
/* create Graph module */
Mgraph = rb_define_module("Graph");
Rgraphbase = rb_define_class_under(Mgraph,"GraphBase",rb_cObject);
rb_define_alloc_func(Rgraphbase,alloc_ldgb_ob);
/* some ruby define methods */
test.rb
require 'rubygems'
require '/home/kelum/workspace/myextension/ext/Rlgem/graph/Graph'
include Graph
puts "some test methods";
i compiled it using these commands
ruby extconf.rb
make
ruby test.rb
but when i execute ruby test.rb it show an error.
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': wrong argument type false (expected Class) (TypeError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from test.rb:2:in `<main>'
please help me to fix this. thanks.

Class redeclaration error on targetEntity="Y" within ZF2

I am facing a weird error within my codebase currently. You can see the full ZF2s project code on my github right here. <- there's a link
I'm having a Module set up with two Entities (X and Y). Entity_X contains a reference to Entity_Y via (targetEntity="Entity_Y"). The Error persist with the FQCN or just the CN itself.
Entity_X:
id int PK,
id_Y int FK,
text varchar
Entity_Y:
id int PK,
text varchar
When loading Entity_Y first and then Entity_X everything is working fine. This remains true for both StandardAutoloader and ClassMapAutoloader. However: when loading Entity_X first with ClassMapAutoloader present, i will be seeing the following error:
Fatal error: Cannot redeclare class Kennzahlen\Entity\Referenzwert (Entity_Y)
in \module\Kennzahlen\src\Kennzahlen\Entity\Referenzwert.php
on line 13
Loading Entity_X first with StandardAutoloader works without any problems, too.
Update
The Problem appears to be within ZF2s ClassMapAutoloader (or Autoloading-Mechanism in General). My Module used the ClassMapAutoloader and using this i've gotten the above mentioned error. When removing the ClassMapAutoloader and simply using the StandardAutoloader, the error vanished into thin air. Thanks to #ocramius and all others i've botheres with this :)
I'm writing a failing test case to try and solve this in doctrine/common. The problem seems to be that silent autoloaders (as explained by #Xerkus) are not compatible with doctrine/common itself. To solve that, use a StandardAutoloader from ZF2 (or from composer) instead of using the ClassMapAutoloader. This will solve the issue until a patch is ready.
Update: patch is being suggested at doctrine/common#216
i have no knowledge of doctrine, but i browsed through source and i think i found issue:
https://github.com/doctrine/common/blob/master/lib/Doctrine/Common/ClassLoader.php#L224
here, this code expects that autoloader will return value evaluated to true, but that is not requirement of spl autoload mechanism, therefore autoloader can return NULL,
To check if i am correct, in in your project in doctrine replace line 224 in Doctrine/Common/ClassLoader.php
} else if ($loader[0]->{$loader[1]}($className)) {
with
} else if ($loader[0]->{$loader[1]}($className) && class_exists($className, false)) {
Ans see if issue is fixed, if i am correct - then report bug to doctrine project

GetModuleFileName from MSI

I try use the "GetModuleFileName" to get current "setup.msi" location use mydll.dll in setup.msi installer.
But always give me "c:\windows\system\setup.msi".
Any body know why ? Plx help .
You mention C++ so I'm assuming that you are creating a Type 1 custom action as described here. If this is so, I'm guessing that you are trying to figure out where the install is occurring from so you can reference a file or something. If so, check out the MsiGetProperty function and the OriginalDatabase property. If that doesn't meet your needs checkout the the MsiSourceList* functions starting with MsiSourceListGetInfo.