Routing / Controller / Model = Blog function

Hello!

I'm fairly new to coding the rails stuff - I'm however a webdesigner and I feel that I need to learn how to break rails apart once and for all.

So I've spent roughly 3 hours on trying to do this on my own but with no success.

My information:

Rails -v = 3.0.0 Ruby -v = 1.8.7 Gem -v = 1.3.7 haml -v = 3.0.25 postgresql 9.0

My goal:

Make some kind of blog-function so I fill in a text_area in a form and when I hit the submit button I want the server to create a file in let's say public/comments. So here comes an example so you will get me 100%.

Me as an administrator makes a post through code. I use javascript to count the amount of post classes so I know what ID to give the next comment for the new file name. and then I make the form where the text_area is at and where the submit button is. so the first post which I wrote with code will have something looking like this:

<script type="text/javascript" src="public/comments/2011_03_1.js"></script>   2011_03 being the ID of the article and the 1 being the ID of the comment.

then when someone comments through the form the 2011_03_1.js file is being made in public/comments so the link only works untill someone has made a post - if not it includes a file that does not exist.

however. in this new file it should say something like this:

document.write('<div class="comment 2011_03">'); //Div to count the messages so JS knows what the next ID is document.write('<h1>USER says:</h1>'); //user ID says document.write('Oh man this blog is epic! wooah!'); //random comment text document.write('</div>'); document.write('<script type="text/javascript" src="public/comments/2011_03_2.js"></script>') //link to the ID #2

and then it goes on - chained. the downside by using this method is that if you need to delete one at the early places then you need to modify everything behind it because of how this system works - but I'm fine with that.

so the only thing I want to know now is someone pointing me in to the right direction for this method: you fill in a text_form and on the serverside a file is being made which is being filled with information such as the above. I've been googling quite a bit about routing and I did not really understand it. same thing with the controller and the model.. I didn't.. quite get it.. I did my best at understanding it but I only got mumbo jumbo. So once again - I'm deeply grateful if anyone can point me to either the right direction or to some code with information on it(without works too) so I can for once finally learn!

and I am not sure if I was supposed to do a 'rake db/migrate' once I was done with the controller / model / routing files.. I know squat hmm

Thanks in advance -abandoned

(in routes.rb)

map.connect 'A', :controller => 'B', :action => 'C'

I am not the king of the djungle - but I did find this information on the web and I suppose that I make a function in controller called "B" and then on page A where the form is I have "action='C'" so they are connected - but this is just pure speculations because I have no idea what so ever. this is pure guesses - can anyone please tell me if I'm correct or anything at all?

(in routes.rb)

map.connect 'A', :controller => 'B', :action => 'C'

I am not the king of the djungle - but I did find this information on the web and I suppose that I make a function in controller called "B" and then on page A where the form is I have "action='C'" so they are connected - but this is just pure speculations because I have no idea what so ever. this is pure guesses - can anyone please tell me if I'm correct or anything at all?

That means that a http request to http://yourserver/A should be routed to the action called C (ie a method called C) in the controller called B. Your form action would be /A (since form actions are urls or paths.

There are some intricacies in routing, but in a nutshell it is the process of decided which controller should handle an incoming web request

I have to say that the approach you've got seems a little far fetched - Why display the comments one by one in this fashion rather than have them all on page to begin with? You might want to take a look at the getting started guide at Getting Started with Rails — Ruby on Rails Guides - it covers created a basic blog post & comments app

Fred Fred

Fred

it is not really displayed one by one it's all displayed on one page linked together through javascript.