Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

Re: [Nitro] Generating scaffolding / stub codes?: msg#00317

lang.ruby.nitro.general

Subject: Re: [Nitro] Generating scaffolding / stub codes?

On 2/21/06, James Britt <james_b@xxxxxxxxxxxxx> wrote:
S P Arif Sahari Wibowo wrote:
> Hi!
>
> I have a newbie questions: is there a way in Nitro to generate
> stub / scaffolding codes (like generate scaffold in Rails)?
> Basically it generate a template-based views and controller
> codes based on the model.

Yes and no.  The "no" part is that Nitro (gen, actually) only knows one
trick: "gen app"

Sadly, that's not exactly true. It also in theory understands gen form. Unfortunately, it appears to have shipped broken in 0.28.0. And doesn't appear to be documented in the usage either.

If you are interested in using it, it's a simple fix. From the ruby installation directory,

Edit
lib/ruby/gems/1.8/gems/gen-0.28.0/lib/gen/form/gen.rb
Search for Nitro::FormMixin and change it to Nitro::FormHelper.

Sample command line is:

$ gen form file_containing_model_to_scaffold Optional_class_name_here optional_file_to_output_to

or

$ gen form models/user.rb User _user.xhtml

It's outputs the xhtml form that would represent the object and can probably be called via render in your pages. It doesn't generate whole pages for you.

On the other hand, I wrote my own controller stub generator with very
little effort.

Perhaps there should be a way for people to submit their own generators
for possible inclusion in future releases.

If you're interested in submitting them, please just email them here. :)
It's not exactly a formal process, but it could be a nice way to pioneer things.

Or if you'd rather not, could you describe a few things that you've automated in addition to controllers?

I'd really like a way for me to bundle up my custom generators as a gem,
so others can install it if they like, with the new generator callable
from the gen tool.  Or teach gen to fetch custom generators from a URL,
perhaps as the Rails folks have done for their community-created plug-ins.

Re: gems;

Looking at the gen script, it seems that if you follow the directory structure gen/#{generator}/gen.rb, or to use your controller generator as an example,

gen/controller/gen.rb

# gen controller params_go_here

would actually find it now thanks to how Rubygems works. Completely untested though. Of course you'd potentially have a lot of collisions if it caught on so some formal system would have to be worked out. I'd imagine that's why the Rails folk went with the plugin idea?

Bryan

_______________________________________________
Nitro-general mailing list
Nitro-general@xxxxxxxxxxxxx
http://rubyforge.org/mailman/listinfo/nitro-general
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
qplus.devel/200...    network.jabber....    debian.qa-packa...    encryption.gpg....    python.dabo.dev...    uclinux.devel/2...    science.mathema...    recreation.pesc...    kernel.ck/2004-...    mozilla.devel.e...    tex.latex.prosp...    ietf.multi6/200...    bbc.cvs/2002-11...    xfree86.newbie/...    jakarta.taglibs...    altlinux.hardwa...    comedi/2002-05/...    horde.bugs/2004...    games.diplomacy...    finance.e-gold....    web.dom.test-su...    lang.ruby.rails...    os.netbsd.devel...    video.gstreamer...   
Home | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation