I am a capable programmer and I write software for a living. I am taking up a new project to build a website that has a bunch of forms that perform CRUD operations on a database and some multimedia. I am very familiar with PHP and Python and have written some websites in them. I have written some rake tasks and a few ruby scripts that run in production, but I never wrote any websites in ruby. I am considering using Rails, but I have the following questions. It would be great to know the answers to any/all of these:
Answering your questions in order:
The project should be done in a month and is very time sensitive. Is 1 month enough for learning with and building a website in RoR?
Given the experience you describe I imagine one month to learn and build a simple-ish app (especially if it is CRUD based) should be enough. If there is a significant level of complexity I would be loath to learn a new technology and deliver a complicated site in one month.
Writing direct SQL queries is one of my strengths and I would like to use it. I heard that RoR is a pain to use if I am writing SQL queries directly. Is this true? Or can I just say execute a query, give me the results (as a list or dictionary) and then I will tell you how to render them?
The rails way is to use the ActiveRecord object mapppings it gives you (and mostly these work very well) It is also very easy to write direct SQL if that is what you want to do
ModelName.find_by_sql('your query')
is how you do that
I have heard that RoR does joins in memory and doesn't use the facilities offered by the database. Is this correct?
ActiveRecord does a lot for you, but wherever performance is an issue, as above you can write your own SQL to leverage the advantages of the database.
I need to create a website that displays a lot of Images, videos and Java applets. Would RoR hinder my ability to do this?
I don't see why it should. There are lots of gems and plugins out there which help with this sort of functionality, so it may well be the case that a lot of code could already be written for you.
I am OK using a PHP framework. Is this a bad idea? If not, which PHP framework is closest to Rails in terms of programming convenience.
I'll let a PHP expert answer this bit.
If it's time-sensitive, stick with what you know.. That said, Rails has lots of plugins to handle things like image-uploads which may save you a lot of time. Rails has "scaffold generators" which create basic CRUD applications in a single command:
./script/generate scaffold title:text description:text when:datetime
..will generate the controllers/views to create/edit/delete items. You can then easily wrap nicer looking HTML around it, add authentication (via restful_authentication), and you may have your completed application in a few hours..
There's very few situation where you'd need to write SQL with ActiveRecord, but you can. RoR is still Ruby code, so you can always use a MySQL library and do away with ActiveRecord if you really need to write raw SQL (but, again, you almost certainly don't)
There's no reason ActiveRecord cannot perform JOIN's via SQL queries, the ActiveRecord::Associations::ClassMethods mentions associations being performed via JOIN's.
Besides, even if it does do JOINs through memory, it's worked perfectly well for however long Rails has been around..
No. They're all just bits of HTML, which Rails can output as easily as any other framework.
Absolutely. If you don't go with Rails, use a PHP framework!
I would recommend against choosing a framework based on "how close to Rails" it is. PHP isn't Ruby. Trying to "port" (in a manner) a framework to a different language rarely works as well as writing a framework for that language.
As I commented on Chuck's answer, "CodeIgniter and Zend are good PHP web-frameworks. CakePHP is a good Ruby on Rails imitation"..
I found CodeIgniter felt much more like PHP (in a good way), it's documentation is also my favourite of any project I've used!
The Zend Framework is very modular, you can drop bits of Zend into an existing PHP app, or use it's MVC routing system.
CakePHP seems to be trying to make PHP act like Ruby, rather than making a framework that fits nicely with PHP.
All that said, the reason you use Ruby on Rails is the community (and thus all the plugins and stuff that revolve around it).
For example, paperclip plugin makes it extremely easy to an image-upload form (along with thumbnailing). To use it you add (to your model):
has_attached_file :photo, :styles => {:thumb=> "100x100#", :small => "150x150>" }
Then in your view, where you want the upload form to be, add:
<% form_for :user, :html => { :multipart => true } do |f| %>
<%= f.file_field :photo%>
<% end %>
That's it.
What I would recommend is spend a day making something simple in Rails. There's countless great tutorials (Railscasts are a good, random, example) and plenty of books on it. See if you like it, if not try CodeIgniter, Zend or CakePHP (or Django, or Merb, or.... Just don't spend the whole month trying frameworks!)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With