Rails not rendering correctly on heroku - heroku

On a new user I validate the uniqueness of a field and if it already exists I add an error with a string from locale.
That has this base format
field_error_message_uniqueness_html: "Already bla bla<br/> if bla bla contact us<a href='mailto:%{email}' target='_top'>%{email}</a>."
When I test on a development enviroment it works great, but on heroku it displays like it wasn't html.
development
Already bla bla
if bla bla contact us info#mail.com
heroku
Already bla bla<br/> if bla bla contact us <a href='mailto:info#mail.com' target='_top'>info#mail.com</a>.
My error adding code
validates_uniqueness_of :field_number,
allow_blank: true,
:message=>(I18n.t :field_error_message_uniqueness_html, scope: "activerecord.attributes.user", email: ApplicationHelper::SUPPORT_EMAIL ).html_safe
What can possibly be messing it?

Try adding .html_safe to your string.
field_error_message_uniqueness_html: "Already bla bla<br/> if bla bla contact us<a href='mailto:%{email}' target='_top'>%{email}</a>.".html_safe

Related

Problem with building an expert system in prolog

I keep getting syntax errors while compiling this code in prolog. I'm new to programming so I don't quite understand. Can someone please help me debug where I went wrong? The expert system was meant to classify animals with vertebrates and invertebrates. This is the code I currently have:
:-dynamic known/3
top_goal(X):-animal(X).
%Animals and their classifications
animal(lion):-
type(vertebrate),
color(brown).
animal(bee):-
type(invertebrate),
color(yellow).
animal(crickets):-
type(invertebrate),
color(green).
%background information about vertebrates and invertebrates.
animal(vertebrate):-
vertebral_column(present),
nerve_cord(dorsal_and_hollow),
skeleton(internal),
heart(located_on_right_side),
haemoglobin(present_in_red_blood_cells).
animal(invertebrate):-
vertebral_column(absent),
skeleton(external),
heart(located_on_dorsal_side),
haemoglobin(dissolved_in_plasma).
%Ask rules
animal(X):-ask(type,X).
animal(X):-ask(color,X).
animal(X):-ask(sound,X).
ask(A,V):-
write(A:V),%ask user
write('?:'),
read(Y),%get the answer
asserta(known(Y,A,V),%remember it
Y==yes.%succeed or fail
solve:-
retractall(known(_,_,)),
top_goal(X),
write('The animal is '),write(X),nl.
solve:-
write('This animal is unknown '),nl.
You have some typos.
ask(A,V):-
write(A:V),%ask user
write('?:'),
read(Y),%get the answer
asserta(known(Y,A,V)), %remember it ***missing ')'
Y==yes.%succeed or fail
and here
solve:-
retractall(known(_,_,_)), % *** missing _
top_goal(X),
write('The animal is '),write(X),nl.
Then some codes are missing: color/1, haemoglobin/1, heart/1,
nerve_cord/1, skeleton/1, top_goal/1, type/1, vertebral_column/1.

rspec: How to expect that page has the desired html

I have below html which I took from the launched page source.
<dt title="No. days">No. days:</dt>
<dd>7</dd>
In my test I have to expect the same html, I tried below
expect(page.html).to include("<dt title=\"No. days\">No. days:</dt><dd>7</dd>")
But got the error.
What format exactly I need to write in the include to expect the same html
Thank you in advance
String is not safe HTML.
expect(page).to have_selector('dt[title="No. days"]', text: "No. days:")
expect(page).to have_selector('dd', text: "7")

How to use $ref for tags between files

I am using Open API 3.0, in A.yaml
# something above
tags:
- name: user
description: Operations about user
- name: user_stuff
description: API for user stuff
- name: another_user_stuff
description: API for another user stuff
# something below
Then, in B.yaml, I want to make reference to the tags in A.yaml, for example the tag of user. Suppose in B.yaml, we have
post:
tags:
$ref: <What are the things should be here?>
summary: do somthing
description: "do something"
requestBody:
# bla bla bla
required: true
responses:
"200":
description: uccessfully
x-swagger-router-controller: B
How can I make a reference from B.yaml to A.yaml?
The tags keyword does not support $ref. All tags must be defined inline.
# B.yaml
tags:
- name: foo
description: Operations to manage Foos.
paths:
/something:
post:
tags:
- foo
- bar
That said, you don't have to define tags in the global tags section in order to use them in operations. The global tags section is used only to define extra tag metadata, such as descriptions and externalDocs, or the tag order in documentation tools.

Ebay Australia Site ID invalid on Trading API (Modified EbayR)

Every time I try and publish a product with AddFixedPriceItem with the Site ID set to Australia (15) I get the error response:
:errors=>{:short_message=>"Input data is invalid.", :long_message=>"Input data for tag is invalid or missing. Please check API documentation."
I tried every variation of the site ID ("AU", "Australia", 15, "15") and when i switch it to the US site ID (0) everything works perfectly. Is there something that I'm doing wrong?
Im using my own customised version of EbayR (because it didn't parse the xml correctly)
Anyway here is the full raw SOAP request:
Headers:
{
'X-EBAY-API-COMPATIBILITY-LEVEL' => #compatability_level.to_s, # => 837
'X-EBAY-API-DEV-NAME' => dev_id.to_s,
'X-EBAY-API-APP-NAME' => app_id.to_s,
'X-EBAY-API-CERT-NAME' => cert_id.to_s,
'X-EBAY-API-CALL-NAME' => #command.to_s,
'X-EBAY-API-SITEID' => #site_id.to_s, # => which is 15
'Content-Type' => 'text/xml'
}
the full body request is:
<AddFixedPriceItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<RequesterCredentials>
<eBayAuthToken>....</eBayAuthToken>
</RequesterCredentials>
<Item>
<Title>dssddsheykduhfid</Title>
<ListingDuration>GTC</ListingDuration>
<ListingType>FixedPriceItem</ListingType>
<Description>This is another test description with image</Description>
<PrimaryCategory>
<CategoryID>57989</CategoryID>
</PrimaryCategory>
<SKU>dfiuhdssdsdfggfmeesddffdeseddfda</SKU>
<InventoryTrackingMethod>SKU</InventoryTrackingMethod>
<PaymentMethods>PayPal</PaymentMethods>
<PayPalEmailAddress>payments-facilitator#logicsaas.com</PayPalEmailAddress>
<CategoryMappingAllowed>true</CategoryMappingAllowed>
<ConditionID>1000</ConditionID>
<Country>AU</Country>
<Currency>AUD</Currency>
<DispatchTimeMax>4</DispatchTimeMax>
<PostalCode>3194</PostalCode>
<ReturnPolicy>
<ReturnsAcceptedOption>ReturnsAccepted</ReturnsAcceptedOption>
<RefundOption>MoneyBack</RefundOption>
<ReturnsWithinOption>Days_30</ReturnsWithinOption>
<Description>What! you dont want the product! .... ok</Description>
<ShippingCostPaidByOption>Buyer</ShippingCostPaidByOption>
</ReturnPolicy>
<PictureDetails>
<PictureURL>http://www.joomlaworks.net/images/demos/galleries/abstract/7.jpg</PictureURL>
</PictureDetails>
<ShippingDetails>
<ShippingType>Flat</ShippingType>
<ShippingServiceOptions>
<ShippingServicePriority>1</ShippingServicePriority>
<ShippingService>AU_eBayAusPost3kgFlatRateSatchel</ShippingService>
<ShippingServiceCost>10</ShippingServiceCost>
</ShippingServiceOptions>
</ShippingDetails>
<Site>15</Site>
<Variations>
<VariationSpecificsSet>
<NameValueList>
<Name>Size</Name>
<Value>L</Value>
<Value>S</Value>
</NameValueList>
<NameValueList>
<Name>Color</Name>
<Value>Red</Value>
<Value>Blue</Value>
</NameValueList>
</VariationSpecificsSet>
<Variation>
<SKU>dfiuhdssdsdfggfmeesddffdeseddfdaOMG454fgfgfg</SKU>
<StartPrice>100.99</StartPrice>
<Quantity>1</Quantity>
<VariationSpecifics>
<NameValueList>
<Name>Size</Name>
<Value>L</Value>
</NameValueList>
<NameValueList>
<Name>Color</Name>
<Value>Red</Value>
</NameValueList>
</VariationSpecifics>
</Variation>
<Variation>
<SKU>dfiuhdssdsdfggfmeesddffdeseddfdaOMG432325fgfgfg</SKU>
<StartPrice>100.99</StartPrice>
<Quantity>16</Quantity>
<VariationSpecifics>
<NameValueList>
<Name>Size</Name>
<Value>L</Value>
</NameValueList>
<NameValueList>
<Name>Color</Name>
<Value>Blue</Value>
</NameValueList>
</VariationSpecifics>
</Variation>
</Variations>
</Item>
Also I bit the bullet and payed the 75 dollars for technical support, If I don't get a response here I'll paste the response from them for all to see.
Cool, so it seems like this was an ebay issue. They are trying to fix it at the moment. But they responded with a work around:
Hello Avin ,
Thank you for reporting this issue. I can reproduce the problem and I have forwarded this to our engineering team for further investigation. We will keep the ticket open in "Waiting-BugFix" status.
Actually SiteID is not a mandatory field. SiteID will be taken from the header if you don&apos;t pass it. As a workaround, please omit the field and continue listing.
Please let me know if you have any questions.
Best Regards,
eBay Developer Support

RubyMine RoR I18n config/locals/en.yml syntax error "file should have single root"

I don't know if this is just a goof syntax error, or if this is something I should legitimately be concerned about. I've searched online for this error and have found very little concerning it. So my guess is that this is either something so "no duh" that hardly anybody ends up with this error, or that it's so obscure that - again - hardly anybody ends up with it. Nonetheless, here we go:
This is what I'm using:
Ruby 2.1.1p76
Rails 4.0.5
SafeYAML 1.0.3
RubyMine 6.3
[should you need anymore information, please ask]
The error I'm getting exactly is: "Rails i18n locale file should have single root"
Here is a shortened version of my en.yml file (I'll include what I believe to be the problem areas)
<%
object_names = **{**
:administrator => 'Administrator',
:activity_log => 'Site Activity',
:answer => 'Answer',
:approval => 'Approval',
:user => 'Member',
:video => 'Video',
:vote => 'Like'
}
section_names = **{**
:approvals => 'Items Awaiting Review',
:advertisements => 'Advertisements',
:ad_placements => 'Ad Placements',
:awarded_badges => 'Badges',
:badges => 'Badges',
:videos => 'Videos'
}
anonymous = 'Anonymous**'
%>
en:
homepage:
mine: "My %{site_name}"
site_name: "%{site_name}"
site_condition_name: "%{site_condition_name}"
titles:
main: "%{site_name}"
delimiters:
minor:** ' **-** '
major: ' | '
scopes:
popular: Popular
newest: Newest
active: Active
my_feed: My Friends
my_activity: What I've Done
tracked_items: "Only <%= object_names[:tracked_item].pluralize %>"
everyone: Everyone
user: "By %{name}"
view: "By %{view}"
sent: "Sent <%= object_names[:message].pluralize %>"
page: "Page %{page}"
letter: "Starting With %{letter}"
query: "%{query}"
category: "%{category}"
**meta_description:**
main: "%{site_name} is a social network that connects people"
footer:
about: "About %{site_name}"
about_alliance_health: About Alliance Health
community_advocates: Community Advocates
terms_of_use: Terms of Use
oh - wow. Ok, it looks like bold isn't going to work inside the code markers. But I'm sure you guys can decipher what's going on. Basically anything that's bold (or delimited with a double asterisk '**') is where the IDE is marking the code with this particular error. So, as you can see, it seems rather chaotic and nonsensical. But I often find that when such things happen, it's usually one tiny little character somewhere that's throwing everything else off.
Now, I'm no YAML expert - in fact, I hardly even know the stuff (which is something I'm planning on changing here in the near future) so this may be something along the "no duh" lines. However, it is interesting to note that the bulk of the error-marked syntax starts with the last single-quote of the word: " 'anonymous' ", all the way down to: " minor: ", skipping the first following single quote, and picking up again on the hyphen, afterwhich there are no more errors for the rest of the nearly 5,500 lines of this file.
Thanks to anybody who helps out. I've been dorking around with this for far too long, and with very little online information on this particular issue. So any help is much appreciated :)
Thanks!
So - I'm not sure this will ever help anybody ... but in the case that it may, this is how I re-engineered the script to avoid the errors. I simply removed the usual delimiters that were causing the parsing confusion. And #mu is too short, you were correct. This is an erb.yml file, though I'm not sure why the original creator left the dual extension off. At any rate - thank you to everybody who offered any suggestions and ideas :)
<%
object_names = Hash.new
object_names[:administrator] = %q<Administrator>
object_names[:activity_log] = %q<Site Activity>
object_names[:answer] = %q<Answer>
object_names[:approval] = %q<Approval>
object_names[:user] = %q<Member>
object_names[:video] = %q<Video>
object_names[:vote] = %q<Like>
section_names = Hash.new
section_names[:approvals] = %q<Items Awaiting Review>
section_names[:advertisements] = %q<Advertisements>
section_names[:ad_placements] = %q<Ad Placements>
section_names[:awarded_badges] = %q<Badges>
section_names[:badges] = %q<Badges>
section_names[:videos] = %q<Videos>
%>
en:
homepage:
mine: "My %{site_name}"
site_name: "%{site_name}"
site_condition_name: "%{site_condition_name}"
titles:
main: "%{site_name}"
delimiters:
minor: ' - '
major: ' | '
scopes:
popular: Popular
newest: Newest
active: Active
my_feed: My Friends
my_activity: What I've Done
tracked_items: "Only <%= object_names[:tracked_item].pluralize %>"
everyone: Everyone
user: "By %{name}"
view: "By %{view}"
sent: "Sent <%= object_names[:message].pluralize %>"
page: "Page %{page}"
letter: "Starting With %{letter}"
query: "%{query}"
category: "%{category}"
meta_description:
main: "%{site_name} is a social network that connects people"
footer:
about: "About %{site_name}"
about_alliance_health: About Alliance Health
community_advocates: Community Advocates
terms_of_use: Terms of Use

Resources