webdevRefinery Forum: [WIP] RoR: Getting started - webdevRefinery Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

User is offline TheEmpty 

  • I say words in sequences.
  • Group: Members
  • Posts: 5169
  • Joined: 02-October 10
  • Expertise:HTML,CSS,PHP,Java,Javascript,Python,Ruby on Rails,SQL

Posted 07 October 2010 - 05:54 PM (#1)

[WIP] RoR: Getting started


ToDo
C01ors


Few rules about RoR
1) DRY - Don't repeat yourself.

Imagine if every time a kid asked you, "are we there yet?" and you had to keep responding: "yes, yes, yes". Your doing the same thing over and over. Pretty annoying right? So the idea here is that if you're using something that is going to be used constantly, put the code in one place (organized! you will learn more about this in a bit)

2) KISS - Keep it simple stupid.

Simple to explain: take the long way home or the short way? Pretty easy to choose.

3) Organization - not only for your room.

Ruby On Rails is based on MVC, this stands for Model View Controller. Almost anything dealing with the database goes into the model. If you have a users table (everything is plural, they hold multiple rows) you would create a User.login(username,password) method, or a current_user.is_admin? function.

4) Ruby is simple & sexy

This is PHP:
function myFunction($a=1,$b=1){
 return $a + $b;
}


This is Ruby
def myFunction(a=1,b=1)
 a+b
end


instead of writing "function" we write "def" for define.
instead of using braces we write 'end'
the last of anything that returns something (such as an addition) automatically returns, but I could also write

return a+b;

or

if a == 0
return true
elsif b == 0
return true
end
return "Nothing returned!"


As you may see, typing "return" ends the processing of the function (this is normal in any language).
Now for another big difference! To use this function in PHP you would need to write.

myFunction;
myFunction();
myFunction(2,5);


But in ruby you can do the following

myFunction
myFunction()
myFunction 2, 5
myFunction(2,5)
myFunction 2 , 5


Now that you have a general idea of what Ruby on Rails is about, this is probably the best way to learn it. But this is a free alternative.

Why aren't I posting my own 'get started'? Guess you didn't read #2 (noticed how I didn't say what it was :P)
Reserved.
0


User is offline Carson 

  • I shall become popular on forrst.
  • Group: Members
  • Posts: 857
  • Joined: 08-March 10
  • Locationbehind you :D
  • Expertise:HTML,CSS,Java,Graphics

Posted 07 October 2010 - 06:02 PM (#2)

i recommend writing your own tuts. the links you gave us is to me overwhelming. and i am interested in learning it to
0


User is offline BokTheGolem 

  • Group: Members
  • Posts: 668
  • Joined: 04-April 10

Posted 07 October 2010 - 06:43 PM (#3)

Personally (and this is totally a personal opinion) I HATE that type of syntax. At least for me it causes so much 9ok not so much just a little unneeded) confusion. for example in php could i not do

function myFunction() {
      return "You ran a function!"
}

output = myFunction();


in which case i know i ran a function which probably returned something.
So in Ruby could i do

def myFunction()
     return "You ran a function";
end

output = myFunction


Did i run a function? Reference another variable? What?
I don't know ruby so maybe this is not possible or acts differently but it just seems unneeded. Not being able to call a function by just its name (Ask myFunction instead of myFunction()) is a feature of php.
"You can't make me look! I'll just shut my eyes."
"Oh, you'll open them. You have to breath sometime. "
0


User is offline TheEmpty 

  • I say words in sequences.
  • Group: Members
  • Posts: 5169
  • Joined: 02-October 10
  • Expertise:HTML,CSS,PHP,Java,Javascript,Python,Ruby on Rails,SQL

Posted 07 October 2010 - 07:01 PM (#4)

Yeah you can use () to define or use the function without passing arguments. Yes it was confusing for me at first too, but it's nice for certain functions such as: link_to :action => 'login'

You ran a method of Self ;) Self is a class.
I'll update my post when I get on the CPU
Reserved.
0


User is offline derTechniker 

  • BadBoy™
  • Group: Members
  • Posts: 1210
  • Joined: 06-July 10
  • LocationAustria
  • Expertise:HTML,CSS,PHP,Javascript,SQL

Posted 08 October 2010 - 01:17 AM (#5)

Will there will be more or is this the whole "tutorial"?
0


User is offline Mark 

  • Group: Members
  • Posts: 549
  • Joined: 08-March 10
  • LocationSacramento, CA, USA
  • Expertise:HTML,CSS

Posted 08 October 2010 - 01:39 AM (#6)

It says [WIP] so i'm guessing there's more
0


User is offline Daniel15 

  • dan.cx
  • Group: Moderators
  • Posts: 3435
  • Joined: 17-April 10
  • LocationMelbourne, Australia
  • Expertise:HTML,CSS,PHP,Java,Javascript,Node.js,SQL

Posted 08 October 2010 - 06:09 PM (#7)

Looks good so far :). I want to learn Ruby one day.

Quote

Ruby On Rails is based on MVC, this stands for Model View Controller.

I believe Kyek wrote an MVC tutorial. Perhaps link to that in this :)
Daniel15! :D
Posted Image

Repeat after me: jQuery is not JavaScript. It is not the answer to every JavaScript-related question. When you have to write some JavaScript, do not instantly react with "Oh, I'll do that with jQuery!"

Spoiler
1


User is offline Tim 

  • Group: Members
  • Posts: 86
  • Joined: 16-August 10
  • LocationSomerset, UK
  • Expertise:HTML,CSS

Posted 08 October 2010 - 08:25 PM (#8)

One major thing that you're lacking is an explanation of what ruby and ruby on rails are.
timmw.co.uk - not much to see here (yet)
0


User is offline Sole_Wolf 

  • Group: Members
  • Posts: 307
  • Joined: 24-March 10
  • Expertise:HTML,PHP,Java,SQL

Posted 04 May 2012 - 06:17 PM (#9)

Just wanted to point out that in the PHP code example, variables have a dollar sign before them. Also, you spelled function incorrectly. :P

Ok, Grammer Nazi mode off.

This was a pretty nice and easy to follow getting started on Ruby tutorial. I am starting to learn it myself and plan on practicing on it a lot during this summer.

Thanks for the intro!
--Sole_Wolf
1


User is offline TheEmpty 

  • I say words in sequences.
  • Group: Members
  • Posts: 5169
  • Joined: 02-October 10
  • Expertise:HTML,CSS,PHP,Java,Javascript,Python,Ruby on Rails,SQL

Posted 04 May 2012 - 06:31 PM (#10)

Hey, no problem Sole Wolf. Thanks for that feedback, I edited the post. I really have to recommend the rails tutorial, railstutorial.org recently updated to include Cucumber, Bootstrap, RSpec, and other "tools of the trade" that [some] successful Rails developers use.
Reserved.
0


User is offline gushort 

  • Group: Members
  • Posts: 460
  • Joined: 05-January 11
  • LocationToronto

Posted 04 May 2012 - 08:04 PM (#11)

I tried the "this" link to the "free alternative", but only ended up on Facebook ... what's the deal with that? (I don't use FB)
0


User is offline TheEmpty 

  • I say words in sequences.
  • Group: Members
  • Posts: 5169
  • Joined: 02-October 10
  • Expertise:HTML,CSS,PHP,Java,Javascript,Python,Ruby on Rails,SQL

Posted 04 May 2012 - 10:16 PM (#12)

View Postgushort, on 04 May 2012 - 08:04 PM, said:

I tried the "this" link to the "free alternative", but only ended up on Facebook ... what's the deal with that? (I don't use FB)

It's a link to railstutorial.org, don't know why you went to FB. I guess the Internet got downgraded.
Reserved.
0


User is offline gushort 

  • Group: Members
  • Posts: 460
  • Joined: 05-January 11
  • LocationToronto

Posted 04 May 2012 - 10:41 PM (#13)

View PostThatRailsGuy, on 04 May 2012 - 10:16 PM, said:

It's a link to railstutorial.org, don't know why you went to FB. I guess the Internet got downgraded.


Alright, that's just plain f'd up. Before it definitely did go to facebook, I even checked the url just before I made the post and it contained a direct link to FB. Now it does go to http://ruby.railstutorial.org/ "by Michael Hart!" - but no "free" stuff there.

The site actually looks like those typical marketing pages that are everywhere, but this one sells RoR training courses for $95 so "Buy it now!" :lol:
0


User is offline TheEmpty 

  • I say words in sequences.
  • Group: Members
  • Posts: 5169
  • Joined: 02-October 10
  • Expertise:HTML,CSS,PHP,Java,Javascript,Python,Ruby on Rails,SQL

Posted 04 May 2012 - 11:45 PM (#14)

View Postgushort, on 04 May 2012 - 10:41 PM, said:

Alright, that's just plain f'd up. Before it definitely did go to facebook, I even checked the url just before I made the post and it contained a direct link to FB. Now it does go to http://ruby.railstutorial.org/ "by Michael Hart!" - but no "free" stuff there.

The site actually looks like those typical marketing pages that are everywhere, but this one sells RoR training courses for $95 so "Buy it now!" :lol:

No, you didn't read it, the third line says "The Ruby on Rails Tutorial book is available for free online." He wrote this book, but didn't sign with a published. So he sells the ebooks, screencast version, etc. for a price, but offers the online version (basically DRM'd) for free. Here is a link to that actual book: http://ruby.railstut...s-tutorial-book
Reserved.
0


User is offline gushort 

  • Group: Members
  • Posts: 460
  • Joined: 05-January 11
  • LocationToronto

Posted 05 May 2012 - 02:13 AM (#15)

View PostThatRailsGuy, on 04 May 2012 - 11:45 PM, said:

No, you didn't read it, the third line says "The Ruby on Rails Tutorial book is available for free online." He wrote this book, but didn't sign with a published. So he sells the ebooks, screencast version, etc. for a price, but offers the online version (basically DRM'd) for free. Here is a link to that actual book: http://ruby.railstut...s-tutorial-book


Ah, I see. Sorry about that. Looks good, even updated for 3.2 :)
0


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users


Enter your sign in name and password


Sign in options
  Or sign in with these services