How to persist custom attributes with Rails 6 ActionText - activerecord

Ruby 2.6.3 / Rails version 6.0.0
Hello !
I implemented ActionText (using Trix editor) in my rails 6 application, where I use elements with custom tags and attributes like:
<word start='0'>My </word>
<word start='1'>Word</word>
I found a way to persist my tag "word" like so:
Trix.config.textAttributes.word = {
tagName: "word",
inheritable: true
}
But can't do the same with my custom attribute "start" which is deleted if I edit my element.
You can find a fiddle of this here: https://jsfiddle.net/pqxce2b4/2/
If anyone knows how to fix this problem or need more informations, please let me know.
Thanks for your help :)

Related

Is "enabled?" method available on Watir and/or Page-Objects for a link?

Yesterday i was working on determining is this link was or not enabled, waiting until enabled in order to click it. I'm using Cucumber + Ruby + Watir + Page-Object gem. The link is very similar to:
<a id="the_link" href="#" disabled="disabled">Proceed with your order</a>
Once you fill some fields, the link is enabled and the source changes to:
<a id="the_link" href="#">Proceed with your order</a>
The idea is to wait until the link is enabled in this way, which works with buttons:
def click_on_link
Watir::Wait.until { self.the_link_element.element.enabled? }
self.the_link
end
...but does not work with the link. I made it work determining if the attribute exists, this way:
def click_on_proceed_form
Watir::Wait.until { !self.the_link_element.element.attribute_value('disabled') }
self.proceed_form_submit
end
Looking for the "enabled?" method at the Watir documentation here or at the Page-Object gem here, it seems that is available for all elements. But looking for the same method in the Watir documentation here, seems it's only available for Buttons, Selects and Inputs.
So, i wonder is there is an "enabled?" method for links (anchors) and, if it exists, how to use it. Can you help clarify this issue, please? Thank you very much!
Watir-webdriver does not support the enabled? method for links. I believe this is because the disabled attribute is not a standard attribute for links.
On the other hand, Watir-classic does support the enabled? method for links. However, it will always return false (again because links cannot be disabled).
Therefore, I think your approach is correct (unless you want to monkey patch the link elements to support the enabled?).
However, you should try to avoid using Watir-webdriver directly where possible. The page-object gem has its own methods for waiting and getting attribute values:
def click_on_proceed_form
wait_until{ !the_link_element.attribute('disabled') }
proceed_form_submit
end

rails 3.1, how to integrate JavaScript in View?

I would like to know please, what is the proper way to enable/ disable an element at page ?
I have a view, but, I don't know the best way to do it ??
Is there a quick helper or gem that would access any element at page and set its HTML properties ?
Shall I put a function in a coffee file and call it from view ? how would I do so ??
Is there a good tutorial to see about integrating coffee or JavaScript with View using the new asset pipeline at Rails 3.1 ??
I found the solution ( for an href link )
in haml, it would be:
:javascript
$('#'+NEXT_PAGE_ID).attr('href', 'javascript: void(0)');
$('#'+NEXT_PAGE_ID).attr('style', 'color: #888888');
I've changed the color to dark gray to look as in-actve ..

UINavController whiting another UINavController

Hi I am new to Xcode/objective c and I need some help.
My application has multiple views and more views within a view
Main View is managing my view 1, 2, 3 & 4 via UINavigationController (segmented switch) no problem there. my problem arises when I am trying to load my View 1.1, 1.2, 1.3 etc.
Yes I have a View1, and 4 more views in it 1.1, 1.2, 1.3, 1.4.
Same for the others Views, View 2.1, 2.2, 2.3 & 2.4.
Changing between views 1, 2, 3 & 4 is no problem.
The approach I am taking to load view 1.1 etc Is to ad another UINavigationController in View 1 and use a tab bar items to switch between my views 1.1, 1.2 etc.
Is this correct or you can not load a UINavController whiting another UINavController.
I been unsuccessful so far.
Thank You for your help in advanced.
To be honest, I don't fully understand your setup. Still, I guess I can answer your question: No, it is not possible to have a UINavigationController within a UINavigationController. Please have a look at the 'View Controller Programming Guide', this section describes how ViewControllers can be combined.
If you need multiple UINavigationController in your app, you should probably separate them in a UITabBarController or by using presentModalViewController.

How to hover over (mouseover) an element in Selenium Ruby?

Anyone know how to hover over an element in Selenium Ruby Webdriver?
My code is like this:
el = driver.find_element(:css => "#foo")
driver.move_to el # How do I trigger a mouseover event on this element?
I'm using selenium-webdriver gem with Firefox in Linux 32-bit.
I used driver.action.move_to(el).perform which differs ever so slightly from the other answers, so I thought I would include it for completeness sake.
Turns out the answer is:
driver.move_to(el).perform
I forgot the .perform.
This works for me:
driver.mouse.move_to el
You need to use Selenium's Action Builder to access more complex actions like hovering (which is what seanny123's answer is demonstrating).
Also, if you are working with a hover, odds are you will need to dynamically wait for it to display before taking your next action (e.g., using an explicit wait).
I put together an example on how to do this -- you can see the full write-up here.
To hover an element:
driver.action.move_to(element).perform
# e.g.
driver.action.move_to(driver.find_element(css: 'a')).perform
To hover an element at a specific location:
driver.action.move_to(element, mouse_x, mouse_y).perform
# e.g.
driver.action.move_to(driver.find_element(css: 'a'), 100, 100).perform

Rails 3: #template variable inside controllers is nil

I have the same problem, as in this question. Did anybody find any solutions for this?
So I can't do like this:
flash[:notice] = "Successfully created #{#template.link_to('product', #product)}.
or like this:
#template.title("Page title is here.")
It worked perfectly in Rails 2.3. The main idea is to find out, how to use helper methods directly from conrollers, not from views.
Thanks.
You're doing it wrong.
First, you should setup the title of a page inside the view, not in your controller.
You can simply place a call to the title helper within your view file.
About the link, flash shouldn't contain HTML. However, you can create the link manually.
flash[:notice] = %Q{Successfully created product.}
I ran into this same problem as well and found that you can use the view_context method.
API documentation here: http://api.rubyonrails.org/classes/AbstractController/Rendering.html#method-i-view_context

Resources