开发者

A website using Ruby alone

I want to write a web application and want to use Ruby. I have 开发者_开发技巧no knowledge of Ruby as of now and I want to write this app. to learn Ruby.

Is Ruby alone sufficient to write a web application or Rails need to be included?


You sound like you're interested in writing something in a barebones fashion.

For that then the Sinatra framework might be more approachable.

You could also use Heroku's service to make the deployment and hosting of your web application simple. I can't overstate how slick Heroku is - it's a masterclass in design and user experience!


The only thing you need to made a simplest web application with Ruby is rack. It's used by all Framework in Ruby. And all server like Passenger/Thin/unicorn/mongrel are rack compatible.

So you can put the must simplest ruby web application like that :


class HelloWorld
  def call(env)
    [200, {"Content-Type" => "text/plain"}, ["Hello world!"]]
  end
end

But the dynamic system are more difficult. So a framework is really helpful.


Yes, you can, depending on your development environment. The most common approach that doesn't use any framework, such as Rails, is to use Apache with modruby/eruby. See http://www.modruby.net/en/ for more information (also wikipedias eruby entry: http://en.wikipedia.org/wiki/ERuby)

And, technically speaking, Rails is just a framework written in Ruby, so it's technically still "just ruby" :)


Here is a list of other frameworks than Rails.

You might want to start with Sinatra : it's really small and lets you focus more on the Ruby-learning than on the framework-learning.


Ruby is sufficient but you would have to wire the http server (like webrick/apache/mongrel) with the application you are writing by yourself.
I'd recommend, as to avoid this wireing, to use a simple basic framework like sinatrarb http://www.sinatrarb.com/


Ruby is sufficient, but I wouldn't recommend it. I would recommend working with a framework until you're comfortable with Ruby.

You may want to start even smaller though.


I would definitely use Rails if I were you. Although you can build a website using only Ruby, it's a bit overkill, and you sure can get a lot more using Rails.

A great start for learning Rails (that's where I started) is:

http://headfirstlabs.com/books/hfrails/

There's a few chapters in there you can read. It's really good, and will give you a nice and solid introduction.

Edit

Also, you can use Mongrel, Webrick, lighttpd, Apache etc with it with no problems


You can start off by checking out Chapter 18 (and the rest) of the "Pickaxe Book" titled Ruby and the Web. You can find the online version here to see the nitty gritty of writing Ruby only scripts for a website. There are many options to choose from, most of which have been already suggested here, that will get your website running much quicker and easier.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜