Is the general feeling that the scaffolded views created can be made
reasonable via an appropriate CSS? Or is it usually the case the people
re-work the views generated?
The views I see seem to use tables as opposed to DIVs with class names.
Does thish imply that trying to make the scaffolded generated views
pretty use CSS is not really possible (sorry - CSS is a bit new to me)
Just trying to see whether I should be looking to either (a) learn more
CSS to make the generated views look better or (b) jump in and hand
modify the generated views.
Is the general feeling that the scaffolded views created can be made
reasonable via an appropriate CSS? Or is it usually the case the people
re-work the views generated?
Hi Greg,
Well, IMO, the name scaffold indicates you’re just using them to prop
the house up while you build it.
The structure of the scaffolds isn’t the same as the structure of the
house.
So when you’re done scaffolding, you wouldn’t just paint the scaffolds
and call it home, you only keep them until you’ve built the house and
then throw them away.
Is the general feeling that the scaffolded views created can be made
reasonable via an appropriate CSS? Or is it usually the case the people
re-work the views generated?
The views I see seem to use tables as opposed to DIVs with class names.
Does thish imply that trying to make the scaffolded generated views
pretty use CSS is not really possible (sorry - CSS is a bit new to me)
Just trying to see whether I should be looking to either (a) learn more
CSS to make the generated views look better or (b) jump in and hand
modify the generated views.
Thanks
I’m kind of a newbie to RoR myself, but not to css. I would say you
could do either way. Tables still has it’s meaning though you could do
without it. You can define a div as a table to and rows and all in css,
but that doesn’t work all the way (in my experience).
Learn css. You will be able to do so many things. Even though the code
generated by scaffold seems a bit old you can still use it with css. Css
is the way to go if you want to develop good looking things and keep up
with standard and where the web is going.
Well that depends on how much you want to modify. If you’re just
talking about table size, colours, etc, then CSS can do it all. But if
you want to completely alter the layout, then you’ll have to modify
the views. I would suggest you learn CSS anyway though. It’s not that
difficult (contrary to what some CSS specialists will tell you), and
it’s very useful. Even if you do have to modify the views, you’ll have
to do some CSS as well.
Hope this helps,
-Nathan
Just trying to see whether I should be looking to either (a) learn more
CSS to make the generated views look better or (b) jump in and hand
modify the generated views.
I am kind of newbee here, but for now I was rewriting my views
completly,
and using CSS2 for nice app design.
Maybe in future, core developers will change scaffolded code into “div”
one?
That would be nice, but I think it is not high priority.
CSS classes to give you the hooks you need. We did use a table for the
list partial, because to me it seems really hard to try and do tabular
data with divs. Yes it can be done, but it is somewhat painful and
seems to be more rigid (having to define column sizes and not allowing
the structure to resize with the data like tables do. But I agree with
everyone otherwise in that divs are much better for CSS layout in
general except for when you actually need a table (then use a table
A definition of tables in css will act as a normal table, dynamic and
fluid. But from what I can remember it’s not supported in IE â?? or
something else that didn’t work in IE (as normal ).
The answer to your question about whether you can modify the scaffold
templates is: absolutely. This is Ruby You can modify the
templates, however I would suggest just copying the scaffold generator
or any other generator that is closest to what you want and then
modify it, creating a new generator.
If the structure of the generated code is good and you have the
necessary hooks, you can often get away with changing the look and
feel with CSS alone. However the rails scaffold generator has some
shortcomings in what it generates (IMHO). So when we were creating a
generator for the MasterView project, we started from that but then
ended up changing most of it out to use divs and to apply the proper
CSS classes to give you the hooks you need. We did use a table for the
list partial, because to me it seems really hard to try and do tabular
data with divs. Yes it can be done, but it is somewhat painful and
seems to be more rigid (having to define column sizes and not allowing
the structure to resize with the data like tables do. But I agree with
everyone otherwise in that divs are much better for CSS layout in
general except for when you actually need a table (then use a table
The answer to your question about whether you can modify the scaffold
templates is: absolutely. This is Ruby You can modify the
templates, however I would suggest just copying the scaffold generator
or any other generator that is closest to what you want and then
modify it, creating a new generator.
In many cases, for a number of pages, all I need to do is:
Point it to nicer CSS
Ask it to use my application layout
Make very small changes but let it use tables
and most of it is taken care of.
These are usually for ‘admin’ like pages where you can add a few fields
as part of setting up and configuring, etc. Any proper page (an
important page of the app) that is accessed regularly is completely
designed from scratch though I use scaffolds initially for that too.
If you override a generator would this imply that if there were
improvements
to the generate in the next version of rails that you would not inherit
them? (I’m guessing yes) - would you see this as an issue?
Well it depends on how you overrode things as to whether you would
pick up the new features.
But I wasn’t necessarily suggesting you override rails scaffold
generator (per say) but simply use it as a starting point to create
your own just like so many others have done. You end up with a
different generator which you can call. The other one is still there
and if you ever want to run the other one to compare the differenences
you can.
So while it is possible to extend a core generator, for most things it
is not really worth the effort especially if the bulk of the changes
are in the template itself. Most people who have written generators
have simply written their own, many starting with what one of the
existing generators does and modified.
If there are signifigant improvements then you can choose to diff the
files and move them over into your generator as well. However since
the rails team believes in only minimalistic scaffolding, you are
probably not going to encounter missing features that often.