I've added the following into initializers/mime_types.rb:
text_plain = MIME::Types["application/octet-stream"].first
text_plain.extensions << "fmf"
MIME::Types.index_extensions text_plain`
This works with Paperclip but I get the following message when running rspec:
MIME::Types#index_extensions is deprecated and will be private.
Are there any other methods of adding a new extension without using the above deprecated method?
According to the thread at Thoughtbot Paperclip Issue #1737, you may be able to use the following pattern to avoid the deprecation warning.
text_plain = MIME::Types["application/octet-stream"].first
text_plain.add_extensions "fmf"
Sorry this answer may not be helpful a year later, but perhaps someone else will find it useful.
Related
cable_ready 4.5.0
rails 6.1.4.1
ruby 3.0.2p107
This is a simple example from the basic tutorial (https://www.youtube.com/watch?v=F5hA79vKE_E) I suspect the error I am getting is because either cable_ready or rails evolved a little and created a tiny incompatibility.
I get this error in the JS console:
It is triggered when in my controller I ask cable ready to:
cable_ready["timeline"].console_log(message: "***** cable ready post created")
Which leads to my timeline_channel to:
received(data) {
console.log("******** Received data:", data.operations)
if (data.cableReady) CableReady.perform(data.operations)
}
My interpretation is perform causes this line in cable_ready.js line 13:
operations.forEach(function (operation) {
if (!!operation.batch) batches[operation.batch] = batches[operation.batch] ? ++batches[operation.batch] : 1;
});
Is finding something in the received data that it doesn't like.
That's where my trail ends. Can someone see what I am doing wrong, or tell me what other code you'd like me to include?
Solution: downgrade the version of the cable_ready javascript library.
I previously (maybe a year ago) did this tutorial using CableReady 4.5, Ruby 2.6.5 and Rails 6.0.4 and it worked like a charm back then as well as today.
But today, I tried this tutorial again on a duplicate project--same versions of CR, Ruby, and Rails and now I get java console errors similar to yours.
TypeError: undefined is not a function (near '...operations.forEach...')
perform -- cable_ready.js:13
received -- progress_bar_channel.js:8
I looked at the output of yarn list and saw that cable_ready was version 5.0.0-pre8 on the bad project and it was 5.0.0-pre1 on the good project. The downgrade could be accomplished with yarn add cable_ready#^5.0.0-pre1 in the bad project folder and now both projects work.
FYI for other newbies like me trying to understand how CableReady works: This tutorial gives another example of CableReady, and was also fixed the same way.
I've upgraded my code to use Swashbuckle.AspNetCore 3.0.0. (
Swashbuckle.AspNetCore.Annotations, Swashbuckle.AspNetCore.Swagger, Swashbuckle.AspNetCore.SwaggerGen, Swashbuckle.AspNetCore.SwaggerUI all are 3.0.0).
And now when I use [SwaggerOperation(OperationId = "MyUniqueId")]
the operationId value is not set, but auto generated.
Any idea how if I am doing something wrong or is it just a new version bug?
Just ran into the same issue.
After looking at the documentation, found the solution.
You need to add the line c.EnableAnnotations() in your startup file, more precisely,
services.AddSwaggerGen(c =>
{
c.EnableAnnotations();
More details are here.
Hope this helps you to!
I'm trying to create a Sitelet with SiteletBuilder in C#:
return WebSharper.Sitelets.Content.Page(...)
However, the class Websharper.Sitelet contains Content both as Struct and Class.
So, this does not compile.
Versions of Zafir-Libraries are
Zafir 4.0.152.29-beta5
Zafir.CSharp 4.0.152.29-beta5
Zafir.Html 4.0.56.95-beta5
Zafir.UI.Next 4.0.102.33-beta5
How to reference WebSharper.Sitelets.Content proberly?
Or is this indeed a bug?
Thanks for the report, created ticket: https://github.com/intellifactory/websharper/issues/645
I have been testing with having using WebSharper.Sitelets; and then using with shorter form Content.Page(...). C# can resolve this for some reason, although the name conflict indeed exists in WebSharper.Sitelets.dll
I am using a REXML Ruby parser to parse an XML file. But on a 64 bit AIX box with 64 bit Ruby, I am getting the following error:
REXML::ParseException: #<REXML::ParseException: #<RegexpError: Stack overflow in
regexp matcher:
/^<((?>(?:[\w:][\-\w\d.]*:)?[\w:][\-\w\d.]*))\s*((?>\s+(?:[\w:][\-\w\d.]*:)?[\w:][\-\w\d.]*\s*=\s*(["']).*?\3)*)\s*(\/)?>/mu>
The call for the same is something like this:
REXML::Document.new(File.open(actual_file_name, "r"))
Does anyone have an idea regarding how to solve this issue?
I've had several issues for REXML, it doesn't seem to be the most mature library. Usually I use Nokogiri for Ruby XML parsing stuff, it should be faster and more stable than REXML. After installing it with sudo gem install nokogiri, you can use something like this to get a DOM instance:
doc = Nokogiri.XML(File.open(actual_file_name, 'rb'))
# => #<Nokogiri::XML::Document:0xf1de34 name="document" [...] >
The documentation on the official webpage is also much better than that of REXML, IMHO.
I almost immediately found the answer.
The first thing I did was to search in the ruby source code for the error being thrown.
I found that regex.h was responsible for this.
In regex.h, the code flow is something like this:
/* Maximum number of duplicates an interval can allow. */
#ifndef RE_DUP_MAX
#define RE_DUP_MAX ((1 << 15) - 1)
#endif
Now the problem here is RE_DUP_MAX. On AIX box, the same constant has been defined somewhere in /usr/include.
I searched for it and found in
/usr/include/NLregexp.h
/usr/include/sys/limits.h
/usr/include/unistd.h
I am not sure which of the three is being used(most probably NLregexp.h).
In these headers, the value of RE_DUP_MAX has been set to 255! So there is a cap placed on the number of repetitions of a regex!
In short, the reason is the compilation taking the system defined value than that we define in regex.h!
This also answers my question which i had asked recently:
Regex limit in ruby 64 bit aix compilation
I was not able to answer it immediately as i need to have min of 100 reputation :D :D
Cheers!
I'm trying to grasp basics of Chipmunk. In some tutorial I found a line:
cpSpaceHashEach(space->activeShapes, &updateShape, nil);
But I get 2 mistakes here:
1) Implicit declaration of function is invalid in C99
2) No member named 'activeShapes' in 'struct cpSpace'
What is wrong? Why doesn't it work? Do I need to include something else?
Just to clarify with some code in case anyone else runs into this problem, instead of
cpSpaceHashEach(space->activeShapes, &updateShape, nil);
you'd use:
cpSpaceEachShape(space, &updateShape, nil);
Apparently this change was done so it is easier to keep the code future-proof since the activeShapes were not meant to be used in this way.
Digging into the changelog: (https://github.com/slembcke/Chipmunk-Physics/blob/master/VERSION.txt)
If you look, you'll find that in Chipmunk 5.x cpSpace.*Shapes were marked as private members of the cpSpace struct in the header. Then, in Chipmunk 6.x, private access was disabled by default and a cpSpaceEachShape() function appeared that almost exactly replaced cpSpaceHashEach() + cpSpace.activeShapes that you are trying to do.