Topic: Layout Problems.....

I have been going through the sample tutorial project called Library - where you create books and subjects and stuff, one thing i noitced was that, you can't start off without a database.

This is a small problem because ppl like me who just do front end design now have to go through the nuts and bolts of creating a db,tables,populating data, creating the controllers etc etc...there's so much of work in here. But rest assured, this is only a single time thingy, but since I am from the visual world I am unable to translate controllers/layouts/views into the design that I wanna develop.

How do you generate a 2 column layout ?...where the menu is on your left, and the resultant content is refreshed on the right.

I don't expect to be spoon fed with the actual code here, but a few pointers that would help me get started....


Re: Layout Problems.....

To help you visualize how a rails app should be laid out.

1) Each controller should handle 1 resource. 1 resource is basically a model, like Post, Comment, Artile, Book, Recipe and so on...

2) a controller always handles the main matter of a page. IF you design a page, think about what is the main content of it. thats what the controller should get from the database, and that's what the view of that action should decorate in HTML.

3) Now for ssidemenus: They are NOT the main content, so the controller should not be involded with that.

4) So, we have a main layout, which is the template all your views will be shown in. Inside it, we have a place for the main content. we place the view that the controller rendered in that place with yield():

<div id ="menu">
#we come to this later
<div id ="maicontent">
  <%= yield %> #here the result of the action's view is printed by using yield.


So now what do about menus? Enter partials:

Partials are basically pieces of a page you can render anywhere, much like you would include some html in php somehwere in the page:

<div id ="menu">
<%= render :partial => "menu"

# yourcontroller/_menu.html.erb
#(partials are prefixed with an underscore [which is NOT used in the render call])
  <li><a> ...


So you can simply put a partial called _menu.html.erb in every controller's view directory, and it will be rendered along with the layout, and always pick the one for the current controller.

Of course that's just basics, there are many ways to fine-tune that for different requirements...

Re: Layout Problems.....


Correct me if I am wrong.....but this is what I have understood....

You first create the DB, then you create the Model, then proceed to create the classes/tables. Next, you proceed to code the controllers or methods that act on the data in your application.

Then in the views, we define the different states that the application can have, and have seperate erb files for each, and the in the layouts folder we have the standard. erb that ties all of this together....

hope i am correct, to a point...

Re: Layout Problems.....

quite, i would say smile

maybe you should
1) get a book
2) read about the basic pricniples of MVC ( )