Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Posts
    366
    Rep Power
    10

    Ruby. I need help getting started.


    Hello folks!

    I'm a nub at ruby. I have the book caled Agile Web Development with Rails (2nd Edition) and I pretty much know a half decent amount.

    Anywho, what I need to do is create a page that allows people to do these things:

    1) Submit content (Logged in)
    2) View content (Logged in or noe)
    3) Create an account, and be either a finder, or a findee. (Both can submit content)
    4) Let the finder be able to find findees based on the location(s) they listed themselves in.

    I just need help getting started. Once I'm started I'm sure I can figure out where to go from there.

    Thanks a bunch
    -Amir
    I have summoned you here for a purpose
  2. #2
  3. fork while true;
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    May 2005
    Location
    England, UK
    Posts
    5,538
    Rep Power
    1051
    I'm a rubyer, but not a railser, so i've lifted the next chunk off the rails site:
    Code:
    rails path/to/your/new/application
    cd path/to/your/new/application
    ruby script/server
    You're running Ruby on Rails! Follow the instructions on http://0.0.0.0:3000/
    You'll need to set up models and controllers then and continue like any other rails application. Try looking at the site
    http://www.rubyonrails.com/
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Posts
    366
    Rep Power
    10
    Originally Posted by LinuxPenguin
    I'm a rubyer, but not a railser, so i've lifted the next chunk off the rails site:
    Code:
    rails path/to/your/new/application
    cd path/to/your/new/application
    ruby script/server
    You're running Ruby on Rails! Follow the instructions on http://0.0.0.0:3000/
    You'll need to set up models and controllers then and continue like any other rails application. Try looking at the site
    http://www.rubyonrails.com/
    Thanks, but thats not exactly what I'm looking for. What I need help doing is getting the baseline of code. Like all the files and stuff.

    Thanks
    -Amir
    I have summoned you here for a purpose
  6. #4
  7. fork while true;
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    May 2005
    Location
    England, UK
    Posts
    5,538
    Rep Power
    1051
    Follow the docs. I can't just write your code for you, that's not what i'm here to do. I'm here to provide assistance with troubles you're having and point out helpful links.

    The tutorial will be enough to get you going.
  8. #5
  9. No Profile Picture
    Avid lithomancer
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2006
    Location
    Croatia
    Posts
    271
    Rep Power
    43
    Just few quick questions. I didn't want to open separate thread just for this.
    How is Ruby on Rails used on site? Is it something like Perl (scripting), or Ajax (framework)? Why would someone prefer Ruby over Python/Perl for scripting?
    IMHO, Perl is most powerful for that purpose.
  10. #6
  11. fork while true;
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    May 2005
    Location
    England, UK
    Posts
    5,538
    Rep Power
    1051
    it's done as FastCGI typically. Ruby is a wonderful language IMO, that's why people like it. Ajax isn't a framework silly.
  12. #7
  13. No Profile Picture
    Avid lithomancer
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2006
    Location
    Croatia
    Posts
    271
    Rep Power
    43
    But I've heard that Perl is most powerful here. And why do you say that Ruby is wonderful language? Because of syntax, or what?

    BTW, I know what Ajax is, but i don't know how to say it in english ...
  14. #8
  15. fork while true;
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    May 2005
    Location
    England, UK
    Posts
    5,538
    Rep Power
    1051
    It's flexible and the syntax is alright (i object to the constant 'end', but then python's classes constant 'self' is worse)

    eg. you can use lambda expressions (blocks) effectively. Like we can loop through a list and print each item like so:

    list.each {|z| puts z}

    Because ruby operates solely on return values (unless you use an inplace modifying method), you can do things like this

    "my string, hello world".reverse.split().reverse.remove(2).each {|x| puts "and the token is: #{x}"}

    or something like that.

    Comments on this post

    • netytan agrees : I'm not a huge Python fan anymore, but if you understand why self is there there's nothing to object to.
  16. #9
  17. No Profile Picture
    Avid lithomancer
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2006
    Location
    Croatia
    Posts
    271
    Rep Power
    43
    "my string, hello world".reverse.split().reverse.remove(2).each {|x| puts "and the token is: #{x}"}
    Nice...
    Then why most people use perl instead of ruby for scripting? It's not that hard to learn new language.
    BTW, I learned PHP&MySQL basics yesterday, and i got book about Joomla! and started reading it. It's amazing what can you do with PHP&MySQL...
    And i'll probably need something for scripting sometimes. As i (still) don't know Ruby/Perl, i wanna know which one's best. Perl has excellent string manipulation and regexp, and ruby... i don't know.
  18. #10
  19. fork while true;
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    May 2005
    Location
    England, UK
    Posts
    5,538
    Rep Power
    1051
    Ruby is the better language, perl has CPAN and is installed on more servers.

    Essentially, ruby will make more readable code and is more fun to piss around with, perl is usually quicker to develop applications because there's usually a module that does exactly what you need. PHP is also a scripting language fwiw.
  20. #11
  21. No Profile Picture
    Avid lithomancer
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2006
    Location
    Croatia
    Posts
    271
    Rep Power
    43
    I'm still PHP beginner. Is it smart to use other scripting languages? PHP supports OO, Polymorphism, etc...

    btw, if i ever need scripting language, i'll try Perl. Good readability isn't important to me. Perl has big community, and lots of modules.
    Also, I rarely see someone looking for Ruby programmers. I see that PHP/MySQL/Perl programmer are most wanted. And i'm business oriented
  22. #12
  23. fork while true;
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    May 2005
    Location
    England, UK
    Posts
    5,538
    Rep Power
    1051
    I could have sworn you came to this forum claiming .net experience...

    PHP is the most wanted IME, perl a touch less so. I'd take php, you will need a good 8 months to properly get to grips with perl (buying a small o'reilly reference has been essential to my perl programming, the syntax is often so tricky that i want to doublecheck it instead of testing and risking it being wrong)
  24. #13
  25. No Profile Picture
    Avid lithomancer
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2006
    Location
    Croatia
    Posts
    271
    Rep Power
    43
    I have much experience with small-medium scaled application developing in C#. I wanted to learn ASP.NET, but my MSSQL died in one accident, and unfortunately, i'm on Dial-up, and my pirate got busted, so i can't get VS2005 from him. (Murphy's laws? ).

    Now i want to learn PHP/MySQL. I'll leave ASP.NET for later.
  26. #14
  27. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Which language is best depends on more factors than you or I can imagine. In terms of expressiveness Perl may well be better since it gives you the flexibility to create new (and in theory) cleaner abstractions.

    In practice it's very rare for Perl programmer (or most programmers for that matter) to "waste time" on abstraction.

    This goes beyond proper code formatting: if you have 10 seeming random operators coming into play no amount of indentation will make it read well!

    The typical solution to poor abstraction in programs is to littler the code with comments detailing every little detail, violating the DRY principle. When the code changes slightly and the comments are outdated these comments make your code even more cryptic .

    (Of course, poor code can be written in any language, but so can good code).


    Ruby, which has less potential for expression than Perl, oddly manages to produce cleaner programs in far more cases. This is in part one reason for Ruby's increasing success.

    Perl may be more productive for the moment but as more modules become available for Ruby the gap between what you can do quickly in each language is rapidly decreasing; spurred on by the fact that once a module has been written it can be easily maintained, and not just by the person who wrote it.

    If I had a penny for every time I've gotten a module from CPAN that didn't work, or was out of date I'd have around 10 pence .

    It sounds low but I done relatively little programming in Perl, so the number of dud modules is actually quite high*. Or at least for what I was doing.


    So choosing a language based on the short term productivity gains is just asking for trouble.


    This is without going into the relative merits of either language; the benefits of there abstract or concrete syntax or the absence of this or that feature. Both are Very capable and will serve you well so why not learn both?

    Perl is the current standard scripting language (especially on *nix) but this is changing slowly. There have been several books pointing at Ruby as the Next big industry programming language.

    You may notice that more and more *nix distros are relying on utilities written in other languages like Python, Ruby and even Haskell.


    I think, eventually, we'll all get back to writing Lisp .

    I hope this was helpful,

    Mark.


    * Most Perl code is messy IME and messy code is hard to maintain so it doesn't get maintained.

    Comments on this post

    • °Oblivion°King° agrees
    programming language development: www.netytan.com Hula

  28. #15
  29. No Profile Picture
    Avid lithomancer
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2006
    Location
    Croatia
    Posts
    271
    Rep Power
    43
    Excellent post, Mark

    Both are Very capable and will serve you well so why not learn both?
    Both languages have same purpose. Why should i learn both if I'm gonna use only one? I wanna learn the one which is more powerful, and has good support. When i learn it, i'm gonna use it for everything, and i'll ~master it after some time.

    Ruby is similar to Python. It has clean code, and is powerful.
    Perl has the best support for regular expressions (very important feature to me).

    I'm still not sure which one is better for me... I wanna develop MMORPGs like http://www.darkthrone.com , hattrick , or herowar . I already have few ideas for some MMORPGs.
    How can scripting language help me here? I just learned some advanced stuff about PHP. PHP has everything i need for MMORPG. Now i'm confused...
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo