I am making a dynamic URL in my rails app like
http://localhost:3000?#{something}=#{something1}
How do I get rid of the hardcoded domain name (localhost in this case). I want to deploy this app to heroku and heroku will give its own domain name. I don't want to again change my code to suit the domain name that heroku gives.
Is this possible?
Replace localhost:3000 with request.host_with_port
http://api.rubyonrails.org/classes/ActionController/Request.html#M000521
Related
I'm getting some errors on my rails app that's doing a lot of cross domain stuff, and i'm trying to find a minor fix for this.
Is it possible to have multiple /cable url's inside the production file so that it uses both or whichever works?
example code:
config.web_socket_server_url = ['wss://example.herokuapp.com/cable', 'wss://www.example.com']
i've tried this, but unfortunately it doesn't work.
If you are using two heroku app, you can store the url of you app to a environment variable and reference that variable in you configuration. First in you terminal
heroku config:set -a YOUR_APP_NAME RAILS_HOST="YOUR_APP_URL"
then set the configuration
config.web_socket_server_url="wss://#{ENV['RAILS_HOST']}/cable"
If your second app is not a in-app case, then your should store complete url for both apps and use
config.web_socket_server_url=ENV['RAILS_HOST']
Say you have set up a domain (my-domain.com) to be used for an app on Heroku (myapp.herokuapp.com). It seems to be working as intended. However, you notice when you check the heroku config, you get this:
HOST_URL: myapp.herokuapp.com
Should you set the HOST_URL to your domain?
This is for a ruby on rails app.
It appears to be important if you want to use _url for any links. _url will use the HOST_NAME var from the heroku config. Since I needed to use that for links within an email, I changed it with:
heroku config:set HOST_URL="my-domain.com"
I've deployed a Rails 3.2 app to Heroku. I would like the app to be accessible from http://myapp.mydomain.com and for routes to be accessible from this url, e.g. http://myapp.mydomain.com/ModelA/1
I've followed the instructions at https://devcenter.heroku.com/articles/custom-domains
When I enter http://myapp.mydomain.com in the bowser addressbar it successfully takes me to the app.
BUT the url is rewritten as myapp.herokuapp.com
I've already added the domain to Heroku heroku domains:add myapp.mydomain.com.
How do I maintain the custom domain throughout my app?
This looks like a DNS config issue. You should check your hosting provider to make sure you have your site set up as a CNAME to proxy.heroku.com, not a redirect or anything else.
(Glad you were able to solve it!)
I have developed a RoR app. I would like to update it to handle more than one customer. For instance, one customer might use ame.requestsys.com and another would be slc.requestsys.com.
Currently on Heroku, I have requestsys.com and www.requestsys.com
I was told that I need to have *.requestsys.com --> is that correct?
If yes, why won't Heroku let me add it?
Thanks
From the command line in the directory of your app do:
$ heroku domains:add *.requestsys.com
You can also do it from the heroku dashboard.
Then setup a CNAME in your DNS accordingly to point to yourapp.herokuapp.com
Try this guide for more info: https://devcenter.heroku.com/articles/custom-domains#wildcard-domains.
Basically what you wanna do is a multitenant app, there are a couple railscasts on the subject:
http://railscasts.com/episodes?search=multitenancy
But thats beyond the scope of the question.
I'm new to rails and heroku, and this may very well seem like a daft question, if so I appologise, but would appreciate someone at least telling me so.
I've followed the heroku "getting started" guide, and managed to deploy a copy of the rails default project. But the url preovided by heroku was http://radiant-ice-84.heroku.com, my question is this:
Does heroku assign a randomly generated url, or have I done something wrong because I don't recognise radiant-ice-84?
Before you closing this question, I would like to say that you in fact could specify the first when you create the app (no need to change again in the setting page) by using:
heroku create your-app-name
If you don't specify a name, Heroku generates one for you. You can change it in your app settings (as you noticed), although a lot of people just buy a domain name and map it to the Heroku-generated name.