How to set a minimal Ruby page on a webserver that can add / edit / delete records? - ruby-on-rails

I am trying to add a page on dreamhost.com to display
record = Record.find(params[:id]) # such as Record.find(1)
print record.content # to show content of this record
and that's it... probably using sqlite or mysql, and want to have the ability to add a record, similar to Ruby on Rails's scaffold.
If using Ruby on Rails, it is probably too big for such a simple purpose, but if I use Sinatra, then it looks like I have to start it on a port (and can't start it on port 80 because it is the dreamhost.com's port)
Can Sinatra or any tool or framework fit this purpose?

Go with Rails
Dreamhost offers Rails already installed and at no extra cost. And knowing Rails will certainly be more useful to you in the future than knowing Sinatra.
So, I don't see the benefit in Sinatra unless you are hosting the server.
Since Rails is a framework, it will give you a basic application easily, despite it's massive internal complexity.
I know this doesn't exactly answer the question, sorry about that, but on a shared-hosting site you will have limited opportunity to fiddle with the configuration. It's easier in this case to go with Rails.

Rails isn't really that heavyweight. Unless you need your "app" to be very high performance, Rails is probably a good solution that'll let you have this up in a matter of a couple hours.
That said, I'm sure Dreamhost has a way for you to run a Sinatra app within Phusion.

I wonder why nobody mentioned Padrino yet. It is lightweight and provides you with a simple admin interface!

Related

What's the benefit of using Sinatra instead of RoR if I'm only need a DB and an API

I need to build a web service, for a mobile game, to manage the states of multiplayer games. I need a database and an RESTful API to access it. I'm very familiar with Ruby On Rails and was thinking of using that since I can throw together the DB and API pretty quickly. However, since RoR is a framework for building web pages and I'm not actually building any web pages, it naturally seems like the wrong technology to use even though it would work. As such, I'm considering using Ruby on Sinatra, but I've never used it before and I'll have to kill some time learning it. For you Ruby gurus, is there an advantage to using Sinatra or a disadvantage to using RoR for what I'm trying to accomplish?
Thanks so much in advance for your wisdom!
You know Rails, you don't know Sinatra. Personally I prefer the latter for things like building APIs, but there's nothing stopping you from doing it in Rails, and there's nothing intrinsically wrong with it either. Unless you want to see this as a learning opportunity for getting into Sinatra, I'd say stick with Rails. Here's some links that might be useful btw:
Building APIs With Rails
Building a Platform API on Rails
It probably depends on your API. If you need more than just a bunch of routes then you will have to come up with your own solutions (authentication, ...).
If all you need is some RESTfulness without the added weight, Sinatra is great. All you need to know is what happens in what route and you're fine. See the Sinatra Readme which has all the information to get started.

When Rails require mod_rails, what about Django, TurboGears, Symfony, CakePHP? Can they deploy using mod_python and mod_php?

When Rails applications seem hard to deploy (or used to be), what about Django, TurboGears, Symfony, CakePHP -- can they be simply deployed using mod_python or mod_php? Actually, won't it need something like a mod_django so that the code can run in a "Django" environment? (Just like Rails' script/console or Rails 3's rails console)
Django applications can certainly be deployed with minimum fuss using mod_python.
That said, experienced people will tell you to use the more lightweight and efficient mod_wsgi instead of mod_python. This too can be done with minimum effort. I have done it on multiple occasions and app deployment was always the least of my worries.
Update
#Rebus has it right:
mod_python is not being actively developed anymore, use mod_wsgi
There are a number of ways to deploy a Django site. See the Django Docs or the Django book. As mentioned mod_python is dead and mod_wsgi is the recommended method. Another method which has been making more noise lately is gunicorn. You can see Eric Holscher's blog post about how easy the deployment can be with it.
For CakePHP if you have a standard PHP installation, you probably, at most, only need to load mod_rewrite. This module is often included in the build, though.

Which authentication gem/plugin should I use for Rails 3 running on CouchDB?

I'm building a Rails 3 application on CouchDB (using SimplyStored gem) and I'd like to use some existing gem/plugin for authentication, instead of building it from scratch.
Problem is, I can't find anything that works smoothly for CouchDB, everything assumes that you're running on ActiveRecord. Do you have any tips?
Try Using CouchRest_Model.
So, in the end I've used heavily customized Clearance gem for authentication. It's very flexible, so you're able to use it even for NoSQL database - but you have to rewrite most of the functionality (not by monkey-patching, all within limits of Clearance customization), which probably takes more effort that to write whole authentication from scratch. While a good-enough solution, but I'm sure there better ones.

What is the limit of Sinatra?

I've been learning the Ruby web framework Sinatra lately, and I'm finding it great to use. Most of the articles and blogs I have read about it seem to assume that it is good only for small websites, or 'tiny' web-apps. Is this true? Can a complete web application be built in Sinatra, or is Ruby on Rails the way to go?
You could, in theory, build an entire web application using Sinatra, and it would offer you more precision control than Ruby on Rails would.
That said, it also removes all of the nice features ruby on rails gives you, such as the Model-View-Controller architecture.
If you're looking to build a web application with database interaction, I strongly advise you use Ruby on Rails.
If you're looking to build a very simple API or something that just takes some data and throws it up onto Twitter or something, go ahead and use Sinatra.
There is no reason that it couldn't be used to build an enterprise website. It's fast and intuitive. Two key things in building a larger web application. While it does lack many of the features of Rails, I am yet to run into a road block.
I personally like the slim nature of Sinatra. It embraces routing instead of making it a headache.
I usually find myself wrestling with Rails, whereas I configure Sinatra to my liking.
As for database interaction, mongo_mapper + Sinatra works very well.

Rails Memcached Caching

I am using memcached in production on a high traffic website and have only just switched to using Rails.
I am using Rails 2.3.2.
My question is: Is caching of of queries done automatically with this version of Rails? Or do I have to explicitly cache these queries?
I have seen conflicting documentation on this issue, and I am afraid of having to restart memcached to see exactly what is happening.
The documentation on this w.r.t rails seems patchy. I would appreciate if you could also point out the best place to read up on this.
Thanks!
Vikram
If you haven't explicitly set out and configured certain actions to be cached they won't be, so I would guess right now that you aren't actually using your memcached like you think you are.
As a starting point I'd recommend reading this article on the different methods of setting up caching within Rails.
I've also found this presentation to be useful as well as this excellent screencast.
If you're looking for help, it would be useful to know more of what you're trying to do: how write heavy is the application? How may pages / views / users are you trying to serve?

Resources