I'm new to rails and ruby and was able to stitch together my first app and launch it on heroku. All is well, and now I'm trying to solve the problem of how to manage my data. I found the plugin called "admin_data" and it seemed to be the right choice.
Admin_data works great locally but when I deploy it to heroku I just get the message "We're sorry, but something went wrong. (500)". If I restrict access I get the correct response of "not authorized".
I have no idea what's going wrong, and more importantly, don't know how to look into the cause of the error. Any tips on getting a verbose message from heroku or tuning admin_data are much appreciated.
Thanks!
'admin_data' by default only works in a 'development' environment.
You can either set your Heroku app to 'development' environment (http://docs.heroku.com/config-vars) or add your environment to an 'admin_data' config file (config instructions for a Rails 3 app are here: https://github.com/neerajdotname/admin_data/wiki/admin_data-security-configuration-for-a-Rails3-application):
AdminData.config do |config|
config.is_allowed_to_view = lambda {|controller| return true if (Rails.env.development? || Rails.env.test?) }
config.is_allowed_to_update = lambda {|controller| return true if (Rails.env.development? || Rails.env.test?) }
end
Related
I have made a flask application at my local computer in the debugging mode and it runs all fine. But when it comes to production, the website gives me 500 or internal server error, which I have no idea what the bug is. I am fairly new to flask production and this has been stopping me from moving forward for quite a few days.
My questions are:
1> in my local development environment, one could always print things out. But how can I see those prints in the production stage?
2> Do I see them through Apache2 log? Where is Apache2 log?
For production, I actually followed the tutorials from pythonprogramming.net. Youtube link is here:
https://www.youtube.com/watch?v=qZNL4Ku1UQg&list=PLQVvvaa0QuDc_owjTbIY4rbgXOFkUYOUB&index=2
To use a very simple example, if the code imports a package which wasn't installed, where can we see the errors?
Thanks in advance.
I've tried to use to use try ... except block for every flask function. Whenever there is an exception, it can be return to the front-end. But what about other errors?
I found out:
Use logging module
Read apache2 log from /var/log/apache2
I hosted my Rails 3.2.13 application in (Ubuntu 14.04 + Passenger + apache2) combination server.
Everything is working perfect in development environment; but in production environment. I got error like below :-
In browser
We're sorry, but something went wrong.
We've been notified about this issue and we'll take a look at it shortly.
Than, I decided to take log report in log/production.log and done some changes like below.
In /config/environments/production.rb file:
config.consider_all_requests_local = true
config.log_level = :debug
Rails.logger = Logger.new(STDOUT)
Rails.logger = Log4r::Logger.new("Application Log")
Even than, log report is not created in /log/production.log file
Do I need to do anything else ? kindly someone assist me to resolve this issue.
Passenger author here. In addition to the Rails log file, you should also look in the web server error log. Learn more about this in the Passenger documentation's troubleshooting section.
I have a following definition in my routes.rb
match "/block/:name/:action" => proc { |env|
#heavy magic happens here
}
I use it for handling rendering of cells. My problem is that the following link:
/block/reporting%2Fother%2Fexample/new?exampleable_id=23736&exampleable_type=Abc%3A%3ASomeType
works perfectly fine in development mode, but in production I get "404 Not Found". The only difference between production and development urls is that the one in development uses http and the one in production uses https. I would understand if I wrote a faulty code my proc block, but for the love of god I can't understand why it is not matched in production environment, when it works perfectly fine in development.
Any hint on how to debug this is highly appreciated. There is not so much hair left on my head.
I got this error even when if I finally launched the project in production environment on my local machine. The thing is we do not use Thin in production. We use passenger. After I finally got passenger working locally, I managed to recreate the error.
It turned out that with passenger, the :name in aforementioned route wasn't interpreted as "reporting%2Fother%2Fexample", but possibly as /block/reporting/other/example/new" with the rest not matched, of course.
I fixed the error by replacing
match "/block/:name/:action"
to
match "/block/*name/:action"
I hope this answer to my own question helps someone in the future.
wow. going super nuts here trying to deploy to staging on heroku cedar from Rails 3.2.2. I've gotten everything to work, but I wanted to run these issues up the flagpole to see if there's something wrong with... me. eheh
Both of these issues give me the not-helpful "We're sorry, but something went wrong." error page. So it was frustrating when I had 2 different issues (that acted like 3) in one deploy (that worked fine on my local).
Heroku won't give me my logs.
when I run
heroku logs
I get a long error message that starts with,
c:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/net/http.rb:762:in `initialize': Permission denied - connect(2) (Errno::EACCES)
so i've been doing all this troubleshooting via small slices of commits. maddening.
Heroku chokes when it can't find an image with image_tag
this works on heroku:
= image_tag("content/portfolio/maskphoto_rubble_rebel_blur.jpg", :alt => params[:photo], :width => "100%")
This doesn't (only difference is an extra letter in the file name, though it works on my local):
= image_tag("content/portfolio/maskphoto_rubble_rebell_blur.jpg", :alt => params[:photo], :width => "100%")
Am i nuts in thinking that heroku should just serve up the image tag as-is and let it just not display, rather than crashing the entire page? I'm running compass; not sure if that has anything to do with anything.
Heroku hates nested expressions in an array ref
this works:
n = f.index(params[:photo]) +1
#nextphoto = f[ n ]
this doesn't (but does on my local):
#nextphoto = f[ f.index(params[:photo]) +1 ]
i guess it's better form to separate expressions, but still. why would it work on my local and not on deploy?
I can't directly answer all of your questions, but here are a few things to look at:
Heroku won't give me my logs.
The error you are getting indicates Permission denied ... Perhaps your account credentials are not setup properly? I see you are on a windows box ... on a unix machine, the heroku client writes a file at ~/.heroku/credentials with the username and what appears to be an API token. Check to see if you have a similar file. You can also check https://toolbelt.herokuapp.com/windows and make sure you have successfully performed the heroku login command.
Heroku chokes when it can't find an image with image_tag
I don't have many ideas here. Perhaps it is related to the asset-pipeline?
Heroku hates nested expressions in an array ref
This one doesn't make a whole lot of sense either. Perhaps the logs can shed some light here. I did notice that you appear to be running Ruby 1.9.3 on your system, and I don't believe heroku supports 1.9.3 yet. Maybe you have hit a version-specific bug.
I hope that helps. Good luck.
I'm new to rails and very new to Heroku, but I've recently hosted my app up on Heroku and am getting the following error in my log:
Started GET "/stylesheets/all.css" for ...
ActionController::RoutingError (No route matches "/stylesheets/all.css"):
I stumbled across this forum (http://railsforum.com/viewtopic.php?id=38540) where someone was able to fix a similar problem by setting config.serve_static_assets = true in their config/environments/prodcution.rb, but this did not work for me. Does anyone have any thoughts on this? To clarify, I only get this error in production, not in dev. Thanks.
Also, rather interesting is that I am actually able to access /stylesheets/styles.css with no problem...
Why not just add a blank all.css file?