Showing posts with label CLASS TUTORIAL. Show all posts
Showing posts with label CLASS TUTORIAL. Show all posts

Tuesday, April 7, 2009

TUTORIAL 1

On this class tutorial we are doing a simple application containing a couple of web pages.
- Create the application named “MyApp” → rails MyApp
- Go into the application folder → ruby script/generate controller say
- Go to the Say folder (rails_apps/MyApp/app/view/say) and create two files using a text sheet and name them as “hello.html.erb” and “goodbye.html.erb”.
- Write into the files as follow using hello. For the goodbye file just replace “hello” by “goodbye”:


- This commands creates a hello/goodbye sentences, next line it would show the date and time, follow by a link to the goodbye/hello page.
- Next step is to define the variables used into the controller: Go to(rails_apps/MyApp/app/controller) and open with the “word pad” the file “say_controller”. And modify to make it like follows:

class SayController <>
def hello
@time = Time.now
end

def goodbye
@time = Time.now
end
end

- Now is ready to run it → ruby script/server (to start the server)
- Open a web browser and type → http://localhost:3000/say/hello



- Click on the link “Goodbye”


That’s it, your first ruby page application.