delete posts on rails server from heroku console - ruby-on-rails

I am developing a rails-backed iOS app that is running on Heroku. The app uses afnetworking to GET and POST to the server. As I am developing it, I make posts to test and see if http requests are working- and they do, but I have all of these test posts that I would like to get rid of.
Is there a way to clean off the production server? Can I delete posts from the console?
I am new to this so any advice about monitoring the server would be greatly appreciated!
Thanks

You should be able to use the below command to clear your DB.
heroku pg:reset SHARED_DATABASE_URL

Related

How could I find out why Rails app throws error for a single, specific URL on Heroku while it works fine locally?

I have a Rails app running on Heroku that serves as the API for a front-end application.
I noticed that for a specific, dynamic URL, /bands/:band_id/members it consistently throws net::ERR_CONNECTION_CLOSED errors which breaks the app.
That specific URL doesn't throw an error when I run the Rails app locally and other URLs work fine on Heroku so I suspect this is a Heroku error but I'm not sure.
I couldn't get deeper in analyzing the problem as the request doesn't even appear in the Heroku logs.
Setup error monitoring on heorku. There are many addons listed under "Errors and Exceptions" category here - https://elements.heroku.com/addons
Eg. You can try Airbrake or Bugsnag. Most likely error is coming from you application. It's best practise to setup error monitoring but even before that you can check your server logs to debugs the issue - https://devcenter.heroku.com/articles/heroku-cli-commands#heroku-logs
Without more details I'm afraid I can only try to help you troubleshoot. Post as much code as you can. The route, the controller action, the view it's rendering, and any relevant logs from localhost and heroku would be a great start.
I've had Heroku requests timeout on my rails apps many times - in development there is often no time limit but if your request is taking too long that definitely could be the issue. How long does the request take on development? It could be as simple as shaving off a few seconds.
Otherwise I would say to check this out:
Heroku websocket connection
Also be sure to clear everything you can on your browser, try other browsers, incognito mode, all of that. Try to isolate the problem to one area - even though Heroku is throwing the error it is almost certainly not causing the error.
Check your routes. Look at everything that is happening with that request in your dev and prod logs and try and find something different about this request. Compare it to others.
It is also a good idea to understand your logs and increase their verbosity -
https://devcenter.heroku.com/articles/logging
What levels of logging are available for Heroku?
Good luck!

Websolr issue in Rails and Heroku

I am maintaining client website which built in rails and Postgres database and deployed on Heroku server.
This website used websolr for search. But suddenly from few days got issue regarding websolr. Got below error:
Error is on websolr: Error: {"code":403,"message":"Cluster is currently read-only for maintenance. Please try your request again in a few minutes. See status.websolr.com or contact support#websolr.com for updates."}
I tried to find out solutions but no any where mention specific this issue.
Let me know if any one have knowledge or faced before same issue.
Thanks
Open a support ticket and Heroku will escalate it to WebSolr.
I got solutions as I discuss with Heroku server guys and send them Websolr link which used in my app.
So, issue was websolr URL. Websolr URL was in maintenance.
Thanks

Is it possible to view a remote database in heroku on my computer (using Induction)?

In my rails 4 application directory, I typed "heroku pg:credentials DATABASE" into terminal to get all the information about the database for my application which is deployed on heroku. Since I'd like to view the data inside my postgresql database, I tried inputting the information into Induction, but it ended up not responding and I was forced to enter the activity monitor and force quit. I followed the same procedure several more times all with the same result. Is my version of Induction faulty? Should I be using a different program to view my database? Or am I doing something wrong?
I'm new to rails, so thanks for your help!
Yes, you can. Heroku Postgres allows connections from outside Heroku's network. The credentials displayed from heroku pg:credentials will be all you need and should work. Maybe try using the official PGAdmin tool instead?

Heroku - 2 apps. How to connect Sinatra app with RoR app and use one database?

I have on Heroku 2 apps - the first is in written in RoR and contains also the database. The second app is written in Sinatra framework and in this app I would need to work with data, which are saved in the database of the RoR app.
I've tried to look over some examples of how to load database data in Sinatra from the database of other app, but I wasn't very successful...
Could you give me please any advices, how to do that?
My best piece of advice would be to create an API on your rails app that your sinatra app consumes (you can use something like fernet for signed auth tokens). Don't have more than one application connect to the same database.
If all you want to do is share the database, you can do so by copying the DATABASE_URL config variable from one of the applications to the other.
You can get the value like this
heroku config --app <app_name_of_app1>
Once to have the value of DATABASE_URL, you can set it for the other app like this.
heroku config:add DATABASE_URL=<long_url_string_from_step_one> --app <app_name_of_app2>

Migrating to Cedar on Heroku and losing URL from heroku.com to herokuapp.com

I'm in the process of doing several major improvements to my main production app on Heroku
This includes : using PostgreSQL in development, upgrading to the latest Rails, move to a dedicated database with Crane, and using thin as a webserver. The "last" thing I wanted to do as a logical step was to upgrade my app to Cedar stack instead of Bamboo. I've followed most of the instructions and have an ok "clone" app.
I'd like to move forward and use this new cedar app instead of the bamboo one.
The problem is that this app main use is as a backend serving API requests to an iOS app. These requests are in the format : xxx.heroku.com/...
It was probably a bad idea to use this url in the first place, but this is it and can't be changed on all our current iOS users.
I can find a way to rename my cedar app xxx. The problem is that it will be xxx.herokuapp.com . I know there is an automatic redirect on heroku, but it seems to be only for GET requests. So all my API requests won't return the XML responses I need for the iOS app.
Any suggestions ? I thought I would be able to use xxx.heroku.app going forward and I'm a bit stuck now.
Simple thing is to replace your bamboo app with a simple app that redirects requests to your new URL.
I would suggest never using the heroku domains as production domains - always put your own domain in front of them.

Resources