Code Monkey home page Code Monkey logo

nested_scaffold's Introduction

nested_scaffold

A scaffold command that generates a set of perfectly working nested resource for Rails 4.2 and 5.

Features

  • Generates a nested child resource with a single command
  • Generates a beautifully working bunch of code
  • Automatically generates the appropriate model associations for ActiveRecord
  • Haml ready

Rails versions

4.2, 5.0, 5.1, 5.2

Install

Put this line in your Gemfile:

gem 'nested_scaffold'

Then bundle.

Usage

% rails generate nested_scaffold PARENT_NAME/NAME [field:type field:type] [options]

(Expects PARENT model to exist in advance)

Example

While "Post" model exists,

% rails g nested_scaffold post/comment name:string content:text

This will create:

  • comment {model, controller, helper, views, tests}
  • nested resource route
  • Post.has_many :comments association

Options

Basically same as the original scaffold.

TODO / known issues

  • namespace (who needs?)
  • third party orms
  • fixture replacements

Contributing to nested_scaffold

Pull requests are welcome on GitHub at https://github.com/amatsuda/nested_scaffold

Copyright

Copyright (c) 2010 Akira Matsuda. The gem is available as open source under the terms of the MIT License.

nested_scaffold's People

Contributors

amatsuda avatar andrewhavens avatar conzett avatar freakent avatar lacostenycoder avatar n0nick avatar pebble8888 avatar rickythefox avatar rudyonrails avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nested_scaffold's Issues

Readme improvements - show output

I'm interested in using this gem but am not 100% set, as I'm not sure what it will do. When you run rails g scaffold model_name you get something like this:

Running via Spring preloader in process 12961
      invoke  active_record
      create    db/migrate/20170816172716_create_model_names.rb
      create    app/models/model_name.rb
      invoke    test_unit
      create      test/models/model_name_test.rb
      create      test/fixtures/model_names.yml
      invoke  resource_route
       route    resources :model_names
      invoke  scaffold_controller
      create    app/controllers/model_names_controller.rb
      invoke    erb
      create      app/views/model_names
      create      app/views/model_names/index.html.erb
      create      app/views/model_names/edit.html.erb
      create      app/views/model_names/show.html.erb
      create      app/views/model_names/new.html.erb
      create      app/views/model_names/_form.html.erb
      invoke    test_unit
      create      test/controllers/model_names_controller_test.rb
      invoke    helper
      create      app/helpers/model_names_helper.rb
      invoke      test_unit
      invoke    jbuilder
      create      app/views/model_names/index.json.jbuilder
      create      app/views/model_names/show.json.jbuilder
      create      app/views/model_names/_model_name.json.jbuilder
      invoke  test_unit
      create    test/system/model_names_test.rb
      invoke  assets
      invoke    coffee
      create      app/assets/javascripts/model_names.coffee
      invoke    scss
      create      app/assets/stylesheets/model_names.scss
      invoke  scss
   identical    app/assets/stylesheets/scaffolds.scss

Can we get something similar for this project in the Readme?

Resources in routes.rb not generated correctly

The generated code puts the end of the resources block on the same line as the following code resulting in an error.

Example:

  resources :projects do
      resources :testmodels
    end resources :projects do
    resources :toggles
  end

should be

  resources :projects do
      resources :testmodels
    end 
resources :projects do
    resources :toggles
  end

Could not find generator 'nested_scaffold'

Hi @amatsuda.

I followed the steps for using gem, but when I try to use the nested_scaffold generator I get the following message: Could not find generator 'nested_scaffold'. I am using Ruby 2.5.0 and Rails 5.1. Would you help me? Thank you very much.

Rspec and slim not found

Running via Spring preloader in process 4480
      invoke  active_record
      create    db/migrate/20180314125001_create_quota_assignments.rb
      create    app/models/quota_assignment.rb
       error    rspec [not found]
      insert    app/models/company.rb
      invoke  scaffold_controller
      create    app/controllers/quota_assignments_controller.rb
       error    slim [not found]
       error    rspec [not found]

Any ideas on this? rspec and slim are being used just fine in the normal scaffold generators.

nested_scaffold views

I am using rails 3.2 and tried your gem, however, it did not generate views. it did generate controllers and models not views.

Bootstrap styling?

Hi. This is an awesome gem. Thank you. I was wondering if you had any future plans to provide bootstrap compatible views in the templates?

not support rails 4

i use rails 4.1 or 4.0

but nested_scaffold gem maybe support rails 3.2.2

i want nested_scaffold support rails 4

Syntax error on Migrate

Having an issue when trying to migrate, syntax error. I am on Rails 4.2.

I ran:
$ rails generate nested_scaffold post/comment [title:string body:text]

$ rake db:migrate
rake aborted!
SyntaxError: /mnt/c/Users/strip/RubymineProjects/thisisgettingcluttered/d/db/migrate/20190409172016_create_comments.rb:5: syntax error, unexpected '[', expecting tSTRING_CONTENT or tSTRING_DBEG or tSTRING_DVAR or tSTRING_END
t.string :[title
^
/mnt/c/Users/strip/RubymineProjects/thisisgettingcluttered/d/db/migrate/20190409172016_create_comments.rb:6: syntax error, unexpected ']', expecting keyword_end
t.text] :body
^
/home/josh/.rvm/gems/ruby-2.2.2/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in require' /home/josh/.rvm/gems/ruby-2.2.2/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in block in require'
/home/josh/.rvm/gems/ruby-2.2.2/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in load_dependency' /home/josh/.rvm/gems/ruby-2.2.2/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in require'
/home/josh/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.0/lib/active_record/migration.rb:774:in load_migration' /home/josh/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.0/lib/active_record/migration.rb:770:in migration'
/home/josh/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.0/lib/active_record/migration.rb:765:in disable_ddl_transaction' /home/josh/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.0/lib/active_record/migration.rb:1048:in use_transaction?'
/home/josh/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.0/lib/active_record/migration.rb:1040:in ddl_transaction' /home/josh/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.0/lib/active_record/migration.rb:994:in execute_migration_in_transaction'
/home/josh/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.0/lib/active_record/migration.rb:956:in block in migrate' /home/josh/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.0/lib/active_record/migration.rb:952:in each'
/home/josh/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.0/lib/active_record/migration.rb:952:in migrate' /home/josh/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.0/lib/active_record/migration.rb:820:in up'
/home/josh/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.0/lib/active_record/migration.rb:798:in migrate' /home/josh/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:137:in migrate'
/home/josh/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.0/lib/active_record/railties/databases.rake:44:in block (2 levels) in <top (required)>' /home/josh/.rvm/gems/ruby-2.2.2@global/gems/rake-12.3.2/exe/rake:27:in <top (required)>'
/home/josh/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:24:in eval' /home/josh/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:24:in

'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.