Normally if I want to test an ROR app in Ubuntu, I run the rails s command and webrick initializes the server which I access by typing "localhost:3000" or whatever in the URL bar of my browser. However, I can't do this without an internet connection. If I'm in the air or just somewhere with no wifi, is there a way to still do this?
Thank you.
Rails loads dependencies through the your OS's http libraries. I don't know the exact terminology, but it basically means your app will use any connection required to make your app run
To explain, this works in the same way as if you access http://google.com & http://localhost:3000 - you still access through the browser, but your system doesn't mind if those URL's are local or public
To answer your question, you'll need to keep your db & assets local to your system. The simple way is to install & run a MYSQL server, and use localhost in your database.yml file to connect to it
Related
As the title suggests, how can I host a Ruby on Rails application on a home server. I want to be able to develop on linux and then deploy on a server running linux. I know there's PaaS out there that help with deployment and host but for a specific job I need to be able to do it on a computer that will act as a server.
Your phrasing 'run a RoR project on a local computer for production' is a little strange.
If you just want to do development on your PC and have somewhere that will host your production app for free and you can push to from your PC (i.e. the way most development works) you want Heroku.
If you literally want to use your computer as the server for a production app you can use something like Ngrok, which creates a tunnel from the web to your localhost. However you would definitely not want to run most applications like this because if you ever shut down or even closed your computer the site would stop working. Additionally I would guess there's security concerns with using your computer as a server for a publicly accessible URL for any extended period, though I don't know that for sure.
I have a Rails app on a windows machine that also has a SQLServer that it used to use as it's database.
However I am trying to transition the app to use a new SQL server on a different Windows machine.
The new Machine is reachable (ping)
After changing the database.yml file with the new IP I can go into Rails console and make queries on the new machine.
However, Running the code still queries the local(old) database.
I have restarted apache.
This is driving me nuts. Why is my code still hitting the old configuration? Do I need to restart the machine completely?
Thanks
Just Try printing the TARGET_ENV and the URI that you are targeting in the Ruby code. It will tell you which IP is being hit everytime.
I am not very experienced, but I have played around with rails a little in the past. When I did it was easy to test the app without actually exposing anything to the internet, since I could just point my browser to localhost. But this app will be getting input from a cellphone so I think it needs to be exposed. What I did so far was to push it to heroku and test there, but that does not seem like a good solution at all since every time I make a change i have push it. I am thinking I have to open a port on my router so and expose the server, which I think I can figure out how to do fairly quickly. Any suggestions on how to try to keep this as safe as possible? Or is there a better solution that I am missing?
The way you could test it if your server and your cell phone are on the same network is just find the local IP address on your machine running the server. You would then go into the browser of the cell phone and type the IP of your browser 'colon' the port the server is listening to (most likely 3000 if a rails server).
So for example if the servers IP was 192.168.0.1 it would be 192.168.0.1:3000
Since you are doing this on an app just put in 192.168.0.1 for the IP of the connection and 3000 for the port. Or if using a url 192.168.0.1:3000 (just like the browser)
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("https://192.168.0.1:3000");
A very simple way is to use Pow in combination with xip.io.
The former is a local webserver that will run any Rack application behind the scenes for you.
Installing is as simple as:
$ curl get.pow.cx | sh
and linking your app in:
$ ln -s <path-to-app> ~/.pow/myapp
Your app is now accessible at http://myapp.dev/ locally.
Assuming your computer's IP is 10.0.1.1 and your cell phone is on the same Wifi network, your app will be accessible on the phone from http://myapp.10.0.1.1.xip.io.
Caveat: you'll be getting Wifi performance, not cellular performance.
I am using Aptana Studio 3 for development of ROR apps. I used run server command and it showed you can access your app on {http//0.0.0.0:3000/}, but when I try to access this URL, it tells me to check your Internet connection. I tried several other ports also but it is not working. I have created/modified the files necessary and migrated the database successfully too. Appreciate any help in running the app over the browser. I am currently using WeBrick Server.
so, in your title you say "on server". what does that mean? when you are running it on a different machine than your own, you need to use the address of that machine or it's domain name. keep in mind that firewall rules might prevent any connection to that server.
when you are ON the machine, via ssh for example, you can try calling the then "local" rails instance with curl http://localhost:3000/ to verify that it is running.
Trying to do something very basic and test my Rails app on my phone.
Starting the server with:
rails s
But when accessing mymachinename.local:3000, Mobile Safari says that the server stopped responding after about 30 seconds.
I do this all the time on other machines, but I have no idea what could be causing it here. Any suggestions?
I've had a similar issue before trying to access the server from a virtual machine, I had to use the following format for the rails server command:
rails s -b your.dev.ip.address
Whoops. Firewall. Don't know why I even had it turned on.