Re: Beginning Ruby

From: phalcos [mailto:[email protected]]

Im quite new to Ruby (unexpected heh?) but is currently planning on
building a website community with it just in order to see how powerful
it accually can be.

Welcome!
Are you planning on using any existing Ruby web framework (Rails, IOWA,
RubyWeb, to name just a few) to build your website, or creating your own
from scratch?

  1. How can I make sure the userinput only contains certain characters?
    Like if I only want my users to be able to give me [A-Za-z0-9], is
    regex the only alternative?

Regex is not your only alternative, but certainly one of the more
flexible/powerful. input.gsub!( /\W/, ‘’ ) # so easy! :slight_smile:
A lot of the frameworks have their own ways to describe and
auto-validate input for you.

  1. Is there any builtin method for converting html-characters
    into safe input, like what htmlspecialchars in PHP does?

See http://phrogz.net/ProgrammingRuby/lib_network.html#CGI.escapeHTML
And again, Rails and others have their own helpers on this front.

  1. Methods for SQL database storage?

Again, more helpers for the frameworks, like ActiveRecord for Rails.
If you’re rolling your own, it depends on the database.
Ruby’s DBI is a RDBMS-independent wrapper:
http://ruby-dbi.rubyforge.org/

  1. Anything else I should think about?

Think about learning one of the popular frameworks. It may be a
significant change from being used to handle every aspect of the
development yourself, but you may find that you like the power and
development speed that they give you.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs