Rails 3.2.11 select box "selected" issue - ruby-on-rails-3

This is perhaps the strangest issue I've ever run across using Rails:
In the process of creating a form select that displays values from 1 - 100% (but saves in the db as fractional numbers) like so (which works fine, showing "93%" selected):
<%= f.select(:foobar, ((1..100).map {|i| [i.to_s + "%",(i*0.01)] }),{:selected => 0.93}) %>
I discovered a bizarre issue with the 'selected' value: the values 0.94 and 0.95 CANNOT BE PRE-SELECTED IN MY APP. As in, this DOESN'T work:
<%= f.select(:foobar, ((1..100).map {|i| [i.to_s + "%",(i*0.01)] }),{:selected => 0.94}) %>
The selected value was originally a db value (of course), but in the debugging process I removed everything else, and hardcoded the values. 0.94 & 0.95 ALWAYS default to .01 (the first value in the group). The values can be selected manually, and saved to the db with no problem. They just can't be pre-selected. I even removed the select and placed it in another form in my app, adding an attr_accessor. Same issue. Every other value behaves perfectly.
Does anyone have any idea what might be going on here, or will I just have to go insane on this one? :)

Related

VueJS | Problem with data displaying correctly (v-if, v-else) - external server

I have a question about data display. Here's a piece of code (component):
<th scope="col">Visiblity</th>
<td v-if="page.visible !== null && page.visible===1">Yes</td>
<td v-else>No</td>
As a result I receive Yes / No.
Everything works correctly on the local server (xampp), however, after placing the project on an external server, the condition does not work. Although I have a value of 1 everywhere in the database, it shows me a value of 0 everywhere.
Can anyone tell me what the problem is?
Edit:
hmm
I made a simple project in Laravel + Vue
I have several elements in my design. For example, draggable, visible-draggable etc. Works, but in list.blade.php I have a table with data from the database. One column brings up visibility with two value options - 1 or 0. After the record is created and saved, everything is fine. In DB I have 0, 1 value, but Vue show all like a "No". I should have "Yes / No" values ​​in list.blade.php.
I will add that I didn't use npm run production before placing the project on the server, but all components work, only v-if, v-else not.

iMacros Tag Line properties

I'm trying to create a macro to log in to a company owned web page. When I record putting the cursor into the User Name text box, the following command is recorded:
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/pdp/qnyfy/resumeSAML50/pdp/startSSO.ping
The problem is that the "qnyfy" part of the tag line changes. The next time I try to record this tag line, every thing is the same except that "qnyfy" changes to something else; which renders my VBA code useless for logging into this web page.
Is there a way to extract this information first, find out what that 5 characters should be and then re-build a string to use the correct tag line?
Windows 7
Excel 2016
iMacros 10.3
Thanks for the help........
OK, #OP opened some parallel Thread on the iMacros Forum (iMacros Tag Line Properties), which allows me to simplify a bit this Answer and to remove a few of the original IF-IF-IF...
(The parallel Thread contains a bit more (Background) Info and more precise Sols/Scripts applied to this specific Script, for those interested...)
First, FCI (Full Config Info) was originally not completely clear, now it is:
=> iMB v10.3, 'Scripting Interface' v10.3, Win7.
("iMacros v10.3" could have meant 'v10.3 for CR 'Free'/'PE'' also...)
(The 'TAG' Statement is truncated is this Thread, it is complete + complete Script in the parallel Thread...)
Several Solutions, I'll go from "simplest" to "more complex":
1- The 'FORM' Parameter can probably simply completely be removed. It is usually not needed, unless there are several Forms on the Page with similar HTML Elements, here the 'INPUT' Field.
2- Same like '1', but using for example the 'CLASS' Attribute or any Attr(s) that might identify this 'INPUT' Field uniquely if there are several Forms on the Page with similar (but not identical) 'INPUT' Fields. (Or by adjusting the 'POS=n' if they are identical...)
3- Same like '1' or '2', but combined with 'Relative Positioning', on some HTML Element that can be identified "easily" and uniquely to be used as the Anchor, either inside ('3a') the same 'FORM' or 'DIV' (=> this 'INPUT' probably has some 'Label' next to it like some "Login:" for example), or just outside ('3b') if that Form has some Name/Title for that "Section", usually in 'H2' or 'H3' Type.
4- Simply replace the dynamic part ("qnyfy") with a Wildcard:
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/pdp/*/resumeSAML50/pdp/startSSO.ping
Sols [1-4] probably provide a "Shortcut" to probably achieve the desired Result, but they actually don't really answer #OP's Qt which was "How to identify/extract/isolate this "qnyfy" 5 Letter String...?"
5- Using first one of [1-4] Methods, manage to tag some Element that will be inside that 'FORM', either the 'INPUT' Field itself or one Element that could be used as Anchor in '3a' (with Anchor Inside the Form), and then use 'Double Relative Positioning' (more Info on the iMacros Forum where I've several times already completely explained the Principle) to identify and tag and extract (=HTM) the complete 'Containing 'DIV'' (or could be 'SPAN', but there will very probably be some (outer) 'DIV' also) containing the 'FORM' to then isolate the "qnyfy" part using 'EVAL', stg like...:
SET !EXTRACT_TEST_POPUP NO
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/pdp/*/resumeSAML50/pdp/startSSO.ping ATTR=CLASS:* EXTRACT=TXT
TAG POS=R-1 TYPE=DIV ATTR=TXT:* EXTRACT=TXT
SET !EXTRACT NULL
TAG POS=R1 TYPE=DIV ATTR=TXT:*&&CLASS:* EXTRACT=HTM
SET Form_ID EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('ACTION:/pdp/'); y=x[1].split('/'); z=y[0]; z;")
PROMPT EXTRACT:<BR><BR>{{!EXTRACT}}<BR><BR>Form_ID:<SP>_{{Form_ID}}_
6- This one actually comes between '4' and '5', it would be by using '3b' to first locate some Anchor outside the 'FORM' and its 'Containing 'DIV'', then only one Level of 'Relative Positioning' would be needed... (And the 'EVAL()' Statement remains the same...)
That's it...! It would help / add some "Reliability" if for example the Class of the Containing 'DIV' can be identified/added.
Not relevant for iMB v10.3 anymore:
And if "iMacros v10.3" meant "iMacros for CR v10.3 'Free'", you'll need to use ['!VAR1'-'!VAR3'] instead of 'Form_ID' as User Defined Vars are not supported in the 'Free' Version...
[All Solutions/Scripts not tested of course...! Hum, I had previously mentioned that I could directly think of 3 or 4 Solutions, here are already 6, ah-ah...!, and there are also different possible Variants on all 6 of them...]
7- In the parallel Thread on the iMacros Forum, I also mentioned and explained about a Sol_7 using the 'EVENT' Mode with or without ID, which wouldn't be of use for this User as the 'EVENT' Mode was not supported in iMB v10.3.
Rmk:
Sol_5 and Sol_6 can actually be used to deal with Dynamic ID's, same Principle...!
>
I might one day have to delete this Answer as I am currently (re)using each time my last 5/5 'Answer_Credit', I each time have to delete some previous Answer, to be able to post a 5th one, as most Users on the 'iMacros' Tag-Channel usually never follow up on their Threads and don't do "+1" or "Accept Solution"..., and all my previous Answers also usually all get downvoted anyway by some "angry" User(s), so I never manage to pass the Threshold for more than 5 Answers, ah-ah...!, tja...!
(No big deal probably as I actually never or very-very rarely answer Threads on SOF as I don't like the Rep-Pts System, I only answered this one because #OP is a "nice User" that I knew from the iMacros Forum, ah-ah...!)
(I still don't know what the 'community wiki' CB means below posting an Answer...?)

Easeljs getBounds, when are dimensions set?

I'm importing someone's createjs application into an application loader which imports each developers application javascript to a global canvas. The application is working standalone but when I load the javascript dynamically I'm getting some strange behavior surrounding the getBounds() function.
I have some text created like this:
dialogText = new createjs.Text(text, 'bold ' + (28 * scale) + 'px Calibri', '#FFFFFF');
Then later on I use dialogText.getBounds() which returns null.
I try console logging dialogText and I can see that it is set and there is a value _bounds which reads null.
At what point do these values get set when the element in drawn to the canvas?
Note: I'm already adding the text to a createjs.Container() which has its bounds set before I run getBounds().
For a quick reference, I pasted EaselJS's update regarding getBounds():
(This dates back from "August 21, 2013", not sure if this is still necessary nowadays, but using setBounds(x, y, w, h) helped me with Shapes today [in 2017] actually!)
Source: http://blog.createjs.com/update-width-height-in-easeljs/
The _bounds property reflects a value that is manually set on the DisplayObject - which is helpful if you know the bounds of something that can't calculate it (like a Shape). It will always be null, unless you set it directly.
I tested your code, and it seems fine. Are you sure the scale or text values are not null? Maybe hard-code them to see if it works.
Do you have a sample somewhere? I noticed in the GitHub issue you posted that you mentioned it worked fine without RequireJS (though you don't mention that here). I would definitely ensure that the values are being set properly.
Here is the fiddle, as well as a simpler one with no EaselJS stage. Note that I have Calibri installed on my machine, so you might get different results if you are loading it in.
Sample code:
var dialogText = new createjs.Text("This is some text", 'bold ' + (28 * 1.5) + 'px Calibrix', '#FFFFFF');
console.log(">>",dialogText.getBounds());

Xpages djCurrencyTextBox with fractional=false

Since clean 8.5.3 Domino has problem with localized numbers with space as thousand separators, I decided to switch to djCurrencyTextBox. But as don't want to display fractional part, I'm struggling with it too. Even on 9.0.1 test server.
If I create simple field using:
<xe:djCurrencyTextBox id="djCurrencyTextBox1" value="#{document1.currency}">
<xe:this.constraints>
<xe:djNumberConstraints fractional="false">
</xe:djNumberConstraints>
</xe:this.constraints>
</xe:djCurrencyTextBox>
It does not recognize any number entered. ( I get message that value is not valid even when I enter just 1)
When add it as dojo attribute directly, it works as expected
<xe:djCurrencyTextBox id = "djCurrencyTextBox1"
value ="#{document1.currency}" >
<xe:this.dojoAttributes>
<xp:dojoAttribute name ="data-dojo-props"
value ="constraints:{fractional:false}" >
</xp:dojoAttribute>
</xe:this.dojoAttributes>
</xe:djCurrencyTextBox >
Any ideas what can cause the issue?
This is a known issue that is not fixed in 9.0.1
Using the first example above, no matter what value you set on the fractional constraint (enable/disable/auto/true/false), the textbox only ever accepts a value with fractional part included (e.g. 567.89), which is incorrect for disable & false values. The second example works as expected with fractional set to true or false.
This is because, looking at the page source, the html output for the first example is:
<input dojoType="dijit.form.CurrencyTextBox" constraints="{"fractional":"false"}" id="view:_id1:djCurrencyTextBox1" name="view:_id1:djCurrencyTextBox1">
The """ parts should not be included in the constraints.
Whereas with the 2nd example, there is no such issue:
<input dojoType="dijit.form.CurrencyTextBox" data-dojo-props="constraints:{fractional:false}" id="view:_id1:djCurrencyTextBox2" name="view:_id1:djCurrencyTextBox2">
As this has not yet been fixed in 9.0.1, all you can do is utilise the workaround that you have posted for the time being.
UPDATE: The fix for this issue is in Release 9 of the v901 XPages Extension Library on OpenNTF

rails simple_form checkboxes reorder

I use
= f.association :some, as: :checkboxes
and got checkboxes like
But I need to reorder by alphabet and draw by columns
I try to reorder with js by counting columns, but faced with situation hen some labels stay near each other in one row, when label no enough long. Maybe js wrong idea and such task can solve by simple_form
= f.association :some, collection: Some.all(order: 'name'), as: :checkboxes
A side note - if you would actually use names that are not digits but are character based it should return then alphabetically by default.