Feature idea: nicer scaffolded views

This is an opinionated feature idea, so please bear with me :slight_smile:
Rails provides scaffold generators; for instance rails g scaffold user name age:integer active:boolean
creates models, controllers and (importantly) HTML views that are very valuable for newbies to experience the power of Rails and to have “something” up and running in the browser with one command:

My feature idea is: can we make these views look a little nicer?
Functionally, they include all the business logic needed.
Visually, they look unstyled, unresponsive and old.
Therefore, 99% of the times, newbies cannot actually use these views unless they edit the related HTML.

If you can go back with your mind to the first time you used Rails, I’m sure you remember the awe at typing one command and being able to see working HTML pages in your browser. If we made those views nicer, the awe would be 10 times as much!

One way to achieve this goal would be to simply change the existing scaffold.css.scss to have better styles.

However… why reinvent the wheel when we can achieve something nice using Bootstrap CSS?

What I suggest is that scaffolded views can simply point to the CDN-hosted Bootstrap CSS and then have a simple HTML structure that makes for better and responsive views (e.g., adding a

).

This would not affect existing Rails apps, or any code edited by programmers. It would simply replace the existing scaffolded view with a
different one, still giving freedom to expert users to change it. Pointing to the CDN Bootstrap CSS would avoid adding an extra dependency
to the code. In the end, it would greatly benefit newbies and not have a
negative impact on anything else.

That’s my… opinion! What do you think?

One way to achieve this goal would be to simply change the existing scaffold.css.scss to have better styles.

However… why reinvent the wheel when we can achieve something nice using Bootstrap CSS?

Why bootstrap ? We don’t need 90% of the classes anyway.
It will also look like Rails endorse/prefers Bootstrap over other frameworks.

What I suggest is that scaffolded views can simply point to the CDN-hosted Bootstrap CSS and then have a simple HTML structure that makes for better and responsive views (e.g., adding a

).

Then it will be impossible to code offline.

I like the idea of having a nicer scaffolding, I agree that the existing one looks outdated and ugly but I’m really against including a CSS / Grid framework because Rails must not do this choice for the developer.

Remember the old time where prototype was the only supported JS framework out of the box. Most of Rails developer switched to Prototype even if they had a preference for another framework. I don’t like when a framework promote other frameworks without real good reasons.

Pointing to a CDN isn’t a good idea either since it’s will exclude offline development.

So to sum up, yes I’d really like to see better scaffolds but to do this we need to find a way to provide choices / options to the user. Maybe he could choose (using command-line options or a gem) if he want to use bootstrap or foundation or something else. Maybe we should only provide a better default CSS file. I don’t know which solution would be the best but I’m sure using Bootstrap (and a CDN!) by default is not the good one.

I like the idea of creating a better presentation for the scaffold, but not by using a 3rd party framework or library.

However, one could make some minor changes to the scaffold code so if a developer were to add bootstrap, foundation, or whatever framework to their project, the generated scaffold code would automatically have it’s styles enhanced by the added framework.

Robert

I am all for grids as a tool in graphic design and architecture (http://www.slideshare.net/huer1278ft/grids-are-good-right), but why some people see the need to transfer them programatically onto their HTML and CSS is beyond me.

I would actually argue that the look of scaffolding should be made even simpler, ie. http://motherfuckingwebsite.com/. Forcing front-end libraries onto a developer is, in my humble opinion, like insulting his or her intelligence.

As they say, “perfection is achieved, not when there’s nothing left to add, but when there’s nothing left to take away”.

Frank

Thanks for your replies. Opinionated feature idea demands opinionated responses!

Here are my thoughts:

In response to Frank:

FWIW, I think the idea could be useful to some but doesn’t belong in the Rails core. For me, Rails is an advanced server-side technology that is very good at a few things that every website needs.

Rails doesn’t meet the demands of today’s front-end UX world, and that’s OK – there are lots of other choices out there for front end technology (bootstrap being one of many).

Personally, I actually think all of the non-essential gems should be removed from the rails new setup. (I’m assuming here that along with your feature we might see the twitter-bootstrap-rails gem become part of the default Gemfile). Rails isn’t bootstrap, it’s not CoffeeScript, it’s not LESS or SASS. By putting those things into the default the community would be giving a sort of “blessed” status to those projects. To me that would be a bad move. (I also think sass-rails, jquery-rails, coffee-rails and turbolinks should all come out of the default rails new install)

If you feel passionately about this tool that will let you generate bootstrap-flavored scaffolding, make a open source gem and gift your work to the community (just like all the people who’ve contributed to Rails have done too). That’s what the whole modular Rubygem system is about.

Hey you know what I just realized, your feature request is already implemented in the seyhunak/twitter-bootstrap-rails gem.

Just include the Gem in your gemfile and your wish is granted ; )

https://github.com/seyhunak/twitter-bootstrap-rails#generating-layouts-and-views

Jason, I understand what you mean.
My main point was not to introduce Bootstrap into Rails; I agree with you that the smaller the number of dependencies, the better.
My point is that scaffold.css already exists in Rails, and it could be improved.
If the scaffold generator was not already part of Rails, then I would agree 100% with you.
But it’s there, and probably for a reason: to help newbies (and everyone else) spin off a new project quite rapidly.
If you remove Bootstrap from the equation, and just think about the scaffold templating, what is your opinion?
Do you think that it should actually be removed from Rails, since you describe Rails as “an advanced server-side technology”.
Or do you think it should be kept there and, eventually, improved?

I’m for to totally drop styles for the scaffolding like Frank suggested and run hooks instead.
External gems could use that to modify the scafolding process, like twitter-bootstrap-rails does.
The default style should never be used in production anyway.

It’s a good question you raise and from a macro level I think the crux of the matter has to do with a deeper question: Is Rails for the newbie or for the experienced developer?

It’s no longer 2005 and Rails no longer really needs to be a “big tent” that is inviting of every hobbyist under the sun. Having said that, I get why Rails still has scaffolding and why it is still in the beginner tutorials.

Personally I never use scaffolding generators, so this question wouldn’t affect me much.

Having mentored more junior devs on teams at various start-ups, my general opinion is that doing it the hard way is better for the learning process. Things shouldn’t be easy. (but hey I’m probably also a bit of a cynic)

It also brings up another fallacy (dare I say antipattern) that I hear commonly: Less typing means less work. (I disagree with that, one of the reasons why I’m not in favor of all of the arguments promoting Coffeescript adoption. Having said that I do use Coffeescript, but I don’t believe the fact that I have to type fewer characters makes me any faster as coding.)

-Jason

Abdelkader wrote:

I’m for to totally drop styles for the scaffolding like Frank suggested and run hooks instead. External gems could use that to modify the scafolding process, like twitter-bootstrap-rails does. The default style should never be used in production anyway.

Abdelkader, is that the opinion of the Rails core group? In short, would you like to see a PR where scaffold.css is gone and documentation is added to specify how to make your scaffolded views look nicer?
Personally, that’s not what I had in mind when I began this conversation (I thought it would be useful to make those views look nicer by default, not uglier by default), but I can see your point.

Claudio B. wrote:

Abdelkader, is that the opinion of the Rails core group? In short, would you like to see a PR where scaffold.css is gone and documentation is added to specify how to make your scaffolded views look nicer?
Personally, that’s not what I had in mind when I began this conversation (I thought it would be useful to make those views look nicer by default, not uglier by default), but I can see your point.

No!, That my personal opinion.
IF the idea is accepted, the PR should target 5.0, that mean after 4.2-stable is branched.
It will also need some PRs for the other gems, such as foundation-rails (bootstrap is already doing that).
nicer by default is a question of taste, what was nice few month/year ago is probably bad now.
No matter how nice we do it, once it because default, the nice effect will fade away with time.
As i said in the previous email, the scaffolder is meant to help you prototype an app, it was never supposed to generate production ready views.