I am trying to display an erb template inside a facebook page tab. I am successful in doing so using wordpress, but with rails I am getting this error.
FBML Error: illegal tag "body" under "fb:tab-position"
The output of wordpress and rails are exactly similar. They are generating the same html. While in case of wordpress the contents are getting displayed in tabs, in case of rails it throws an error.
Has anyone successfully implemented a facebook app with page tabs using rails.
Is your template being rendered with a layout? Usually the layout would have head and body tags, which you don't want in your facebook content as it's in the context of a page (facebook) that already defines the head and body. To render a page without layout pass the :layout => false option to your render call.
You are most likely getting an error and the body tag is getting in there from the 500.html or the 404.html.
I tried a million things and I found that I had an invalid authenticity token. To see if this is your issue try:
skip_before_filter :verify_authenticity_token
In your controller that is rendering the view.
As the error message says, in a tab you can't have a 'body' tag. Are you 100% sure the Rails output doesn't somehow have it?
Basically you have to supply Facebook a stripped down HTML as they have their own 'head' and 'body' tags.
Related
I'd like to have a link in an email (opened on an iOS devise) open an iOS app.
I have Rails mailer template that contains a link, which opens the app 'myapp' on an iOS device:
<%= link_to 'Reset my password', "myapp://?password_reset_token=#{#token}" %>
This link is rendered properly when used in a regular view, displayed in a browser.
The problem is when the link is used in a mailer template it displays without the href:
<a href>Reset My password</a>
I get the same results when I put the <a> tag manually in the template instead of using link_to. Still results in blank href.
It seems that using any protocol other than http or https yields the same results.
Is there any way to make this non http link display properly
The way I got around this was to adjust my url like this:
"myapp://myapp.com?password_reset_token=#{#token}"
The addition of the 'myapp.com' part made it work, and I can just ignore that part, and parse out the query params that I need.
Above solution do not work as
when I check mail in gmail the href remove from mail, it looks like <a href>Reset My password</a>
So I have done a workaround for it
I have redirected to a route and in that I embed script as below
<script>
$(function(){
window.location = "myapp://myapp.com"+window.location.search
})()
</script>
so it will redirects with all parameters to the URI
im trying to make a web page in Ruby on Rails but im having some problem trying to split my page into various ERB files to split my page in: head,foot and body, now my question is how can i call each one of my views, in my body page to build the entire web page. thanks!
Let's say you have a _header.html.erb, you call it inside you application.html.erb by typing 'render 'header' (without the underscore) in your body tag
everybody.
I was using Devise for authentication in Rails 4 and got some troubles with Devise. When I enter the link: http://yourdomain.com:3000/users/edit.535db919486f611779000000 , it just render the text "You need to sign in or sign up before continuing." without rendering layout, instead of redirect to login page (see attachment)
I guess Rails understand the numeric after "edit." is format and it didn't know how to render it.
What I want is when user enter any link without logged in, it will redirect to login page. Could anyone help me?
With this link, it throw an unknown format exception.
Your problem is to do with the passing of a value after . - EG edit.234234324 or login.23424234
As you can see from your screenshot, you're receiving the error because Rails is treating the number as a format (in the same way it would treat .html, .js or .json as formats)
I don't know why it works for edit, but it looks like it's rendering json to me, probably because it's confused with the type of format you've sent
The way to fix this is to get your config/routes.rb & URLs fixed
You've not detailed how you're sending the numbered requests to your URL helper, but if you're requesting pure URLS, you need to remove the number from the end:
localhost:3000/users/login
localhost:3000/users/edit
These are the URLs which should load (with no numbers)
I would imagine you are getting the error because you're calling the devise url helpers like this:
<%= link_to "login", user_new_session_path(some_value) %>
You just need to use user_new_session_path
I'm using the "web_app_theme" gem. The problem is that the flash error and warning messages don't work.
For example, in the Sign In page it does work; but in the Forgot Password page it doesn't work. I tested it by displaying the contents of the flash <%= debug flash %>.
This is what I get in the Sign In page...
!ruby/object:ActionDispatch::Flash::FlashHash
used: !ruby/object:Set
hash:
:alert: true
closed: false
flashes:
:alert: Invalid email or password.
now: !ruby/object:ActionDispatch::Flash::FlashNow
But in the Forgot Password page I get...
!ruby/object:ActionDispatch::Flash::FlashHash
used: !ruby/object:Set
hash: {}
closed: false
flashes: {}
now: !ruby/object:ActionDispatch::Flash::FlashNow
I'm thinking that it might be related to not using haml. In the Sign In page I'm using haml but in the Forgot Password page I'm using erb. I'm confused because the contents of 'flash' should be the same regardless of the format, right?
This has little to with the view code you use.
From your question, it's clear that the flash in the Forgot Password page has not been set.
Either that or it has been set and erased. Using HAML or ERB is not relevant since the Rails flash is present in both pages.
Check the controller code for the same and verify what should be in the flash on that page.
Also, while there is no hard and fast rule, it is strongly advised to use only one template / view engine (erb or haml) in a single application.
On the Forgot Password page, is the flash object being set and the page then rendered, or is it being set and then a redirection to the page happening?
The normal use case for flash is that you assign to it and then redirect to another page where flash is present. If you want to use flash and then display it's contents in the same action (such as then rendering a template)
Instead of writing (e.g.)
flash[:notice] = 'Foo Bar'
You write
flash.now[:notice] = 'Foo Bar'
I am working on window 7 and facing issue with render
render :js => "alert('Hello')".
But it is not getting alert.
Do any one have experience with this issue.
You should make the call using AJAX so you should add the param "remote: true" to the link or form that is making the call to that action
Be sure that there is client side requested with JS format, as in that cases Rails set up content type for js, and not text/html.
It seems like you are trying to debug your code. Using a before_filter is not the best way. A request can only render once.
I suggest adding statements to your logging, and using the javascript/development console of your browser (Chrome/Firefox): this will show what goes over the wire perfectly,a dn what is executed on the client, and why it fails (if it fails).
Hope this helps.