I want to design a blog using RoR. It is also my initial step with RoR.
I want to learn both Ruby and Rails with this real-life project that
will be live on the net.
Since I am from a .NET background, I use a language of Toolbox with
Controls on it. How to display blog posts one after the other as we see
in blogs? Is there any Ruby control that is similar to .NET Repeater
control?
Rails is too complicated. The typical way to learn rails is to copy an
app out of a book, and you will have very little understanding of what
is going on--especially if you don't know ruby at an intermediate level.
I have read few pages of Beginning Ruby by Peter Cooper. I can learn
fast when I write a real-life project and implement techniques of the
book and forums.
The development model is different than asp.net. There aren’t any controls. In case of the repeater, you iterate over the collection. Very rough sample code
Controller:
def index
@posts = Post.all
This fetches all posts and stores it in an instance variable named posts
end
in your view you iterate over this:
@posts.each do | post|
<%= post.message %>
This iterates over each element of posts and prints the message. Obviously you want do adorn this with the correct html elements.
And I agree that jump starting into a simple project is the best way of doing it. You will also want to look into rubygems.org
PS: The first week will be tough, but then you will see a sudden rise in productivity.
What are the initial steps? I have a little knowledge of PHP as well and
with that limited knowledge I think first I need to design a web-page
using HTML and CSS. Later I need to write Ruby classes and integrate
code within those nasty HTML DIVs.
Is there any free Ruby front-end that can help? I have Aptana 3
installed. Anything better than that?
If you’re really interested in learning Rails and your first step is going to be writing HTML and CSS, you might be doing it wrong. Same thing with focusing on the editor you use.
Watch the flow in the Rails blog example video link (or the Rails guide that Martin linked to), and notice the flow of development. Then try writing your own code (borrowing heavily from these materials) to built your own app.
What are the initial steps? I have a little knowledge of PHP as well and
with that limited knowledge I think first I need to design a web-page
using HTML and CSS. Later I need to write Ruby classes and integrate
code within those nasty HTML DIVs.
Guess what? After you figure out all the complexities of programming
your site with rails, then you have to make it look good. CSS may be
more complicated than rails.
I am going through the tutorial link you provided. It discusses about
assumptions made by Ruby. One such assumption is: "Keeping code DRY
(Don't Repeat Yourself)". Is Ruby assuming the drawbacks of code
re-usability that is popular throughout programming paradigm?
I am going through the tutorial link you provided. It discusses about
assumptions made by Ruby. One such assumption is: "Keeping code DRY
(Don't Repeat Yourself)". Is Ruby assuming the drawbacks of code
re-usability that is popular throughout programming paradigm?
Quite the opposite:
Situation 1: you have a method with 20 lines of code that performs a
calculation, and every time you need to execute that code you call the
method.
Situation 2: every time you need to do do the calculation, you write the
20 lines of code in your app.
Which situation would you deem to be the one that repeats itself?
Lots of people, especially beginners, copy and paste a lot of code. Just about everyone’s done it, and it’s a great way to get started and get something that works, but the resulting code can be brittle and hard to maintain because you’ve got the same or similar logic spread out everywhere. Classes and OO are tools, but they don’t insure against bad coding practices.
You’ll hear the term “refactoring” a lot. Look it up, and get to know what it means. It’s how you get from the kind of spaghetti I was describing to high-quality, DRY code.