Failed to send invitation email with devise_invitable - ruby-on-rails

I deployed my app to heroku recently. When i try to send out an invite to anyone i get the following error.
ActionView::Template:Error (invalid type sequence in UTF-8)
In my template I added <%# encoding: utf-8 %>.
I am stuck at the moment since it was working well in development enviroment

Did you try running magic_encoding from the command line? You might have missed a Controller that needs the #encoding utf-8. Can you show us some code? Are you using any characters (Japanese, etc.) in your Controller?

Related

How to fix an error related to UTF-8/ASCII

Ok, I've got an App built using Rails 4.2 and MongoDB (MongoId V4) for storage. The information (text) stored in some of the tables/collections is a mix of English and Danish. The App is not localized in any way/shape/form yet as it is an API only.
I have a Sidekiq worker that updates the documents in my database. The problem I'm having is that every time a document is updated in Sidekiq, I get the following error:
Encoding::UndefinedConversionError: "\xE9" from ASCII-8BIT to UTF-8 output in Sidekiq.
How can I fix that?
I think you can use enforce encoding to utf8 using string.force_encoding(Encoding::UTF_8) before you update that specific record

ios - Custom Parse Sever on Heroku and MongoLab error 3080 : JSON text did not start with array or object and option to allow fragments not set

I am facing an error with mongoLab, Heroku and deploying a parse server.
I followed this blog post : https://blog.heroku.com/archives/2016/2/4/running-parse-on-heroku
I visited Github, clicked the deploy button and then deployed my app to Heroku.
Next I installed parse using cocoa pods and then set my app keys to the same ones as my app deployed on Heroku like so:
​
Then, I wanted to test it out so I created a quick object and attempted to save it:
​
Then, I tried running my app and I get an error in the console:
​
Why is this happening? How can I fix this error? I am really lost because it appears I did everything right...
Any help greatly appreciated!
The problem in my case was that I had an #symbol in the password and I had not url-encoded it. When I escaped the symbol it started working.
AH! This was so stupid!
All I had to do was make sure my url included the mount
So it was my original_url/parse that got replaced in my sever url in my app delegate!

My manually created json.jbuilder files produce error, rails g jbuilder files do not, why?

Context:
Workstation is Widows 7, using Sublime Text3, Rails 4.1.7
I aimed to build my first API, and found Matthew Sullivan's blog post at https://codelation.com/blog/rails-restful-api-just-add-water. More specifically I followed Beryllium's post at http://blog.berylliumwork.com/2014/09/rails-and-angular-data.html which is verbatim Matt's post with the exception of an added option to the routes setting a default parameter for the format, and different model names.
I followed both posts to the letter, and the api calls worked correctly, json output shows in the browser.
I then applied the same modules to one of my on-going projects. Calling the API produced the error message
undefined local variable or method `json' line#1 of the index.json.jbuilder file
I tried to trace down the cause of the error and did the following:
looked through all lines of code in the modules/controllers, and view .json.jbuilder files, corrected any mistakes, error message persists
called the index.json.jbuilder and show.json.jbuilder that is created by scaffold, no error message, then called the api's separate index.json.jbuilder and show.json.jbuilder error message returns (the problem must be the api's json.jbuilder files or something still in the modules)
after more tinkering, searching stackoverflow for an answer and creating a few more new projects to test (all which did NOT display error message), I "saved as.." every api file in my project as UTF-8 just to be sure. error message persists
I had created the api's json files using the 'new file' from Sublime Text3, then 'saved as..' into my project (UTF-8). So, I decided to delete the api's index.json.jbuilder and show.json.jbuilder files, and replace them using 'rails generator jbuilder' no more error message
Question: Why would this error message occur and this fix rectify it? I assumed it was a problem with rails, my code, but now it seems the actual files, or maybe even my own box.

getting "invalid multibyte escape: /^\xFF\xFE/ (SyntaxError)" error on Heroku

I'm using the VPIM gem for rails to create vcards for users based on their profile information.
It all works fine on my local host, but when I deploy to Heroku, the app crashes.
I'm getting the error below in the heroku logs, which I assume is what is causing the app to crash...
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in `require': /app/vendor/bundle/ruby/2.0.0/gems/vpim-0.695/lib/vpim/vcard.rb:678: invalid multibyte escape: /^\xFE\xFF/ (SyntaxError)
2013-10-27T15:52:14.211497+00:00 app[web.1]: invalid multibyte escape: /^\xFF\xFE/
Any idea on how to fix this issue?
Here's the gem I'm using and some possible solutions that I haven't been able to get working yet. It might be because of my level of understanding of ruby-on-rails.
Gem: github(dot)com/fraser/vpim-rails
Possible solutions:
https://github.com/sam-github/vpim/issues/5
https://github.com/GetJobber/vpim-rails/commit/0c92b5d7f9b2f6a59bdeea3127dbb668072371cc
Any help will be much appreciated.
-Ethan
There is a quick fix for it. Open the following file
"/app/vendor/bundle/ruby/2.0.0/gems/vpim-0.695/lib/vpim/vcard.rb"
in text editor, and add the following line at the beginning of file.
"# encoding: ISO-8859-1"
This solved it for me.

Sending mail from Rails works at console but not in my application...?

I have a pretty simple Rails app and I want send an e-mail when a work request is created. I'm pretty new to Rails so I found some details on how to do it online. Set up a Mailer, configured it, etc. Set up my templates. Fine.
In my work_requests_controller.rb I have:
def create
#work_request = WorkRequest.new(params[:work_request])
respond_to do |format|
if #work_request.save
# Tell the mailer to send a welcome Email after save
PersonMailer.work_request_init_email(#work_request).deliver
format.html... etc.
In know mailing is working because if I go to the Rails console, create WorkRequest object, and use that exact same line (PersonMailer.work...) it sends the mail just fine. But when I create a work request in my application no mail is received, no error is displayed in the browser or in logs/development.log.
In the server output I see the HTML version was rendered, and I see the info about the e-mail and it all looks both hunky and dory. Since I get no errors I'm at a loss as to how to proceed.
OK, I am officially an idiot. :-)
Working on a different problem, I was editing application.rb. I figured I needed to restart the server to make it see those changes. Suddenly, the e-mails work from inside the app.
D'oh! I did not realize (rookie mistake) that I needed to restart the server for the app to see the e-mail configuration I had placed in environment.rb yesterday. I never tried that for some reason.
I see now that and other components are run only when the server starts up. So of course, when I started up console of course it runs all the initializers and so the e-mail configuration was visible to it and the e-mails were sent.
So the answer is, restart your server, stupid. Well, anyway, at least it's working now...I'll take it where I can get it!
I would start with moving your email command to your WorkRequest model as a 'after_create' action
after_create :send_init_email
def send_init_email
PersonMailer.deliver_work_request_init_email(self)
end
See if that works, or aleast gives you a better error msg.

Resources