Open ThomasBush opened 11 years ago
So I got this all figured out, check out my app if you get a chance. Nothing fancy, just a simple short link app I built to learn how to build a linux server and launch a rails app. http://trunc8.me
Sorry I didn't get back to you quicker, but glad you got it working. I was going to mention that Capistrano is the standard way to deploy Rails apps if you're not using Heroku.
It handles deploying/rolling back of apps, migrating remote databases and maintaining logfiles across deployments, as well as situations where you do or do not have direct access to your remote git repo from the deployment server. I recommend you check it out even if you do have something working, because it covers all sorts of edge cases you may not think of in advance.
Here's an excellent intro to using it that covers most of the bases.
I talked with Keith who helped me refactor my app a bit. I am trying to add a feature to where a new short link is not created in my app, if that exact link already exists in the db.
https://gist.github.com/ThomasBush/17eb1b1ed8505395a903
I have included a gist of relevant code. The app generates tokens and stores the visit count correctly, however does not respect the code intended to stop the creation of a new link if that address already exists in the db.
links table in my db: :in_url => my generate hash :out_url => the link submitted by the user :count => number of times this link has been viewed :http_status => http status associated with the redirect (301 default)
Made a minor edit to make the self.check_url
method protocol independent. This fixed the regex to accept an optional secure connection.
I have looked over the self.get_link
method a number of times and don't see an issue. How would I write code to check the contents of my objects in the browser? For example, if this was js I typically use console.log(variable) to check the value of objects as a method of debugging. Does something similar exist in that could be used in ruby?
@walsh1kt and I have had a lot of success recently with Pry. You add it to your rails gems, then add binding.pry
at the point you want to pause your program. If you start your server at the command-line using bundle exec rails server
then that process will pause, output the code in your current method and let you examine or even change anything you want in your code. It has the standard step
, next
and continue
behavior you'd expect in a debugger so you can see how things work over time. Terrific for exploring your code!
Also better_errors turbo-charges your failure pages in the browser and it uses pry internally. Highly-recommended.
West Michigan Ruby's own @Ross-Hunter did a blog post about both of these tools recently that's worth checking out.
I am having a bit of confusion. I created a simple app this weekend in rails, set up a linux server, and am attempting to launch my app.
I created a git repo pushed my local app to it, but now am having trouble pulling the app. Would I create a new rails project on the server and than clone to that? I am a bit confused on the process here. Now when I pull I get all kinds of merge conflicts which are a nightmare to solve as I am not a very experienced git user. Is there a proper order? I could clone first, but than I am missing a ton of file due to the .gitignore, right?
Thanks for any help you can provide.