Git Product home page Git Product logo

nifty-generators's People

Contributors

andersondias avatar drnic avatar giuseb avatar nhocki avatar ognevsky avatar ryanb avatar semaperepelitsa avatar tomwolfe avatar walterdavis avatar wheels avatar wiehann 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  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

nifty-generators's Issues

Rails 3: error when generating scaffold in admin namespace

rails g nifty:scaffold admin::city name:string
After it, one can see this line in routes.rb:

resources :"admin/cities"
And this line broke any other scaffold:
/usr/lib/ruby/gems/svn/gems/actionpack-3.0.0.beta4/lib/action_dispatch/routing/route_set.rb:146:in `module_eval': /usr/lib/ruby/gems/svn/gems/actionpack-3.0.0.beta4/lib/action_dispatch/routing/route_set.rb:147: syntax error, unexpected '/', expecting ';' or '\n' (SyntaxError)
...            def hash_for_admin/cities_url(options = nil)    ...
...                               ^
/usr/lib/ruby/gems/svn/gems/actionpack-3.0.0.beta4/lib/action_dispatch/routing/route_set.rb:149: syntax error, unexpected keyword_end, expecting $end
              end

ruby 1.9.3dev (2010-05-08 trunk 27674) [x86_64-linux]
Rails 3 beta 4

Support Rails built in i18n system for easy translations

It'd be nice it the generated views could be readily modified to use Rail's build in i18n system, so that all the phrases would be found in an en.yml file which could easily be translated into other languages. This feature could of course be a non-default option.

gem installation on Windows XP x64 bits

I tries to install it locally after downloading it from gemcutter:
[code]
C:\Documents and Settings\MACHINE_DEV3\My Documents\libs\gems\rails3.0>gem install nifty-generators -l
Successfully installed nifty-generators-0.4.1
1 gem installed
Installing ri documentation for nifty-generators-0.4.1...
ERROR: While executing gem ... (Errno::EINVAL)
Invalid argument - ./</cdesc-<.ri

C:\Documents and Settings\MACHINE_DEV3\My Documents\libs\gems\rails3.0>ruby -v
ruby 1.9.2p0 (2010-08-18) [i386-mingw32]

C:\Documents and Settings\MACHINE_DEV3\My Documents\libs\gems\rails3.0>
[/code]
Any idea ? Here is the gems list:
[code]
C:\Documents and Settings\MACHINE_DEV3\My Documents\libs\gems\rails3.0>gem list

*** LOCAL GEMS ***

abstract (1.0.0)
actionmailer (3.0.0)
actionpack (3.0.0)
activemodel (3.0.0)
activerecord (3.0.0)
activerecord-oracle_enhanced-adapter (1.3.0)
activeresource (3.0.0)
activesupport (3.0.0)
arel (1.0.1)
builder (2.1.2)
bundler (1.0.0)
erubis (2.6.6)
gem_plugin (0.2.3)
i18n (0.4.1)
mail (2.2.5)
mime-types (1.16)
minitest (1.6.0)
mongrel (1.2.0.pre2 x86-mingw32)
mysql (2.8.1 x86-mswin32)
nifty-generators (0.4.1)
polyglot (0.3.1)
rack (1.2.1)
rack-mount (0.6.13)
rack-test (0.5.4)
rails (3.0.0)
railties (3.0.0)
rake (0.8.7)
rdoc (2.5.8)
ruby-oci8 (2.0.4 x86-mingw32)
sqlite-ruby (2.2.3 mswin32)
sqlite3-ruby (1.3.1 x86-mingw32)
thor (0.14.0)
treetop (1.4.8)
tzinfo (0.3.23)

C:\Documents and Settings\MACHINE_DEV3\My Documents\libs\gems\rails3.0>
[/code]
So the 'nifty' gem is on the list. Normal?

What really do these things do

So, this is a tiny "issue" ... but really, nothing is telling me
what to expect from these things? What is the difference between
nifty_scaffold and normal scaffold?

I came across these in the wonderful advanced search railscast, and no doubt
experimentation will tell me something, but it would be nice if the README
at least gave a clue!

Rspec controller specs now fail

The rspec controller specs are now failing, because of their reliance on "integrate_views." The new verbiage is "render_views." Go figure.

Error in login.html.haml template

The login.html.haml template still(?) uses :login instead of :username. Obviously this breaks login since the user-model has no :login attribute. (I guess most people don't use --haml with nifty_authentication?)

Help file erroneously says --rspec unnecessary if /spec exists (Rails 3?)

Your help file from Rails 3 (3.0.0 final; ruby 1.9.2-p0/head) says:

"Tests or specs are also generated depending
on if you have a "spec" directory or not."

However I had a spec/ directory and when I executed the following:
rails g nifty:scaffold Tag

I got a test/ directory created.

When I did:
(first: rm -rf test, then:)
rails g nifty:scaffold Tag --rspec

I instead got a spec/ dir... with the correct spec file generated.

Incorrect Filename for Session Model

when I run
script/generate nifty_authentication --haml --rspec --authlogic Account UserSession
it creates the model class UserSession but the file it is created in is named app/models/account_session.rb instead of user_session.rb

and later rails throws an error saying it is expecting the class AccountSession to exist (based on the filename)

undefined method `title'

I get

ActionView::Template::Error (undefined method `title' for #<#Class:0x00000104e331b8:0x00000104e31458>) on line #1 of /Users/user/src/blah/app/views/articles/index.html.erb:
1: <% title "Articles" %>

for the nifty:scaffold generator, this is with the latest gem version, rails 3 beta 3, and ruby 1.9.2dev

rails generate nifty:scaffold Article title:string description:text

Missing these required gems: nifty-generators = 0.3.0

For some reason I am unable to by pass this error. I have it added it to environment.rb as :
config.gem "nifty-generators", :version => '0.3.0'

am I doing something wrong or missing anything?

Thanks,

Arif Yayalar

error generating nifty scaffold using Rails 3 beta 4 without active record (with no database)

I made a new project using rails new dummy -O (as a test), added nifty-generators to my Gemfile, and bundle installed it. And then, sadly:

$ rails g nifty:scaffold metrics index

/Library/Ruby/Gems/1.8/gems/thor-0.13.7/lib/thor/core_ext/hash_with_indifferent_access.rb:26:in `[]=': can't modify frozen hash (TypeError)
    from /Library/Ruby/Gems/1.8/gems/thor-0.13.7/lib/thor/core_ext/hash_with_indifferent_access.rb:26:in `[]='
    from /Library/Ruby/Gems/1.8/gems/nifty-generators-0.4.0/lib/generators/nifty/scaffold/scaffold_generator.rb:51:in `initialize'
    from /Library/Ruby/Gems/1.8/gems/thor-0.13.7/lib/thor/group.rb:36:in `new'
    from /Library/Ruby/Gems/1.8/gems/thor-0.13.7/lib/thor/group.rb:36:in `start'
    from /Library/Ruby/Gems/1.8/gems/thor-0.13.7/lib/thor/base.rb:378:in `start'
    from /Library/Ruby/Gems/1.8/gems/thor-0.13.7/lib/thor/group.rb:29:in `start'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.0.beta4/lib/rails/generators.rb:164:in `invoke'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.0.beta4/lib/rails/commands/generate.rb:10
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.0.beta4/lib/active_support/dependencies.rb:212:in `require'
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.0.beta4/lib/active_support/dependencies.rb:212:in `require'
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.0.beta4/lib/active_support/dependencies.rb:198:in `load_dependency'
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.0.beta4/lib/active_support/dependencies.rb:554:in `new_constants_in'
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.0.beta4/lib/active_support/dependencies.rb:198:in `load_dependency'
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.0.beta4/lib/active_support/dependencies.rb:212:in `require'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.0.beta4/lib/rails/commands.rb:17
    from script/rails:6:in `require'
    from script/rails:6

Hmmm.

I just tried rails g scaffold_controller metrics, and it also complained. No value provided for required options '--orm', it told me. Because that's nil when you don't have a database, I think?

Add attr_accessible in models

More often than not you should have attr_accessible in your models to restrict which attributes the user can set. This is a security problem in many apps. The model generated by nifty_scaffold should automatically add attr_accessible. For convenience it can default to including all columns mentioned in the generator. But at least the line is here for further customization and it is easy to remove if the model does not have an external user interface.

Cannot generate singular name with nifty_scaffold

This is not a huge issue but I wanted to pass it on.

running this command generates a "pluralized" version of the name I pass it, and then I have to go and convert each file name and class / module declaration back to singular again. Maybe a flag to pass (similar to passing --haml) to keep it singular?

script/generate nifty_scaffold Home index

its not a huge issue but it is a hassle to go and rename several files and a folder, and then go and edit the controller and helper and functional test files to change the name to the singular version, and update the routes.rb.

Using:
nifty_generators 0.4.0
rails 2.3.8

Error when generating a scaffold on Rails 3

rails generate nifty:scaffold product

...gems/thor-0.13.6/lib/thor/core_ext/hash_with_indifferent_access.rb:26:in `[]=': can't modify frozen hash (TypeError)

Bundler version 0.9.24

bundle show
Gems included by the bundle:

  • abstract (1.0.0)
  • actionmailer (3.0.0.beta3)
  • actionpack (3.0.0.beta3)
  • activemodel (3.0.0.beta3)
  • activerecord (3.0.0.beta3)
  • activeresource (3.0.0.beta3)
  • activesupport (3.0.0.beta3)
  • arel (0.3.3)
  • builder (2.1.2)
  • bundler (0.9.24)
  • capistrano (2.5.18)
  • devise (1.1.rc1)
  • erubis (2.6.5)
  • haml (3.0.4)
  • highline (1.5.2)
  • i18n (0.3.7)
  • mail (2.2.1)
  • memcache-client (1.8.3)
  • mime-types (1.16)
  • mocha (0.9.8)
  • net-scp (1.0.2)
  • net-sftp (2.0.4)
  • net-ssh (2.0.22)
  • net-ssh-gateway (1.0.1)
  • nifty-generators (0.4.0)
  • polyglot (0.3.1)
  • rack (1.1.0)
  • rack-mount (0.6.3)
  • rack-test (0.5.4)
  • rails (3.0.0.beta3)
  • railties (3.0.0.beta3)
  • rake (0.8.7)
  • sqlite3-ruby (1.2.5)
  • text-format (1.0.0)
  • text-hyphen (1.0.0)
  • thor (0.13.6)
  • thoughtbot-shoulda (2.10.2)
  • treetop (1.4.5)
  • tzinfo (0.3.20)
  • warden (0.10.5)
  • will_paginate (3.0.pre)

Formtastic Support

There should be a --formtastic option one could pass in nifty_scaffold or nifty_authentication which would use the simplified formtastic methods to generate form fields.

Depreciation Warnings

Looks like nifty scaffold generates some not so compatible rails 3 code :(

$ rails g nifty:scaffold user username:string email:string password:string --haml

DEPRECATION WARNING: f.error_messages was removed from Rails and is now available as a plugin. Please install it with rails plugin install git://github.com/rails/dynamic_form.git. (called from block in _app_views_users__form_html_haml___3646798309746030193_38225180__1996457461889590104 at /usr/local/apache2/htdocs/ucravewiki/wp/app/views/users/_form.html.haml:2)

also a generator that used formtastic for forms would be awesome! Do you know if anyone is working on one?

Have only *one* nifty generator

There are quite a few nifty generators and it really fills up the generator listing. This also discourages me from adding more.

Instead maybe there could be a single nifty generator which the first argument is the specific generator to use. For example:

script/generate nifty scaffold item name:string

If no generator is specified it could list them all with a short description.

$ script/generate nifty
scaffold - ...
layout - ...
authentication - ...

Rerunning scaffolds?

The scaffold generator works fine and everything but what if I just change like one thing in the migration file (for example add another db column) -- is there a way to rerun the generator without retying everything int he console?

Support Rails 3

Add Rails 3 support. See this fork for an example. I plan to rewrite the generators along with the tests. I will try to keep the features roughly the same except for the nifty:scaffold naming style so it matches the new Rails generators.

For the tests, I will look into using Cucumber and have it run the generator and run the generated test files in an example simple Rails project. See the Dr. Nic's generators for an example of this.

Rails 3 offers generator options where one can specify what tools they use (rspec, shoulda, factory girl, formtastic, mocha, etc.). Look for this and change the default generator options instead of simply looking for the "spec" directory like I am now.

Scaffold fails when DB has not yet been created (Rails 3)

  1. Create a clean Rails app and install devise on it

  2. rails g devise:install

  3. rails g devise User

  4. rails g nifty:scaffold User

    /home/michael/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.0/lib/active_record/connection_adapters/sqlite_adapter.rb:295:in `table_structure': Could not find table 'users' (ActiveRecord::StatementInvalid)
    from /home/michael/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.0/lib/active_record/connection_adapters/sqlite_adapter.rb:186:in `columns'
    from /home/michael/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.0/lib/active_record/base.rb:679:in `columns'
    from /home/michael/.rvm/gems/ruby-1.9.2-p0/gems/nifty-generators-0.4.1/lib/generators/nifty/scaffold/scaffold_generator.rb:194:in `model_columns_for_attributes'
    from /home/michael/.rvm/gems/ruby-1.9.2-p0/gems/nifty-generators-0.4.1/lib/generators/nifty/scaffold/scaffold_generator.rb:55:in `initialize'
    from /home/michael/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.3/lib/thor/group.rb:226:in `new'
    from /home/michael/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.3/lib/thor/group.rb:226:in `dispatch'
    from /home/michael/.rvm/gems/ruby-1.9.2-p0/gems/thor-0.14.3/lib/thor/base.rb:389:in `start'
    from /home/michael/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/generators.rb:163:in `invoke'
    from /home/michael/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/commands/generate.rb:10:in `<top (required)>'
    from /home/michael/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require'
    from /home/michael/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `block in require'
    from /home/michael/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:225:in `block in load_dependency'
    from /home/michael/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:591:in `new_constants_in'
    from /home/michael/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:225:in `load_dependency'
    from /home/michael/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require'
    from /home/michael/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/commands.rb:17:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'
    

rails db:migrate followed by re-issuing the command works.

undefined method `products_index_path'

I'm following along Railscast 142. I used nifty generator to create a scaffold called "products." When I go to the path /products/new I get this error:

undefined method `products_index_path'

There was also another error on the "/products" path, where Rails complained that it couldn't find the path called "new_products_path". I changed products to product and it worked fine, but I don't know how to fix this one because it is thrown from this line:

<%= form_for @products do |f| %>

Any help would be great.

Nifty Layout: application.html.erb Invalid Markup

WC3 Markup Validation Service responds with this error msg related to nifty_layout's application layout template:

Line 2, Column 1: Missing xmlns attribute for element html. The value should be: http://www.w3.org/1999/xhtml

โœ‰ Many Document Types based on XML need a mandatory xmlns attribute on the root element. For example, the root element for XHTML might look like:

Nifty Layout's generated markup:

Including or excluding xmlns="http://www.w3.org/1999/xhtml" changes css style rendering.

Installation problem: Errno::EINVAL, ./</cdesc-<.yaml

Hi everyone,

I tried installing nifty-generators today but I got an error message upon installing RI documentation.

ERROR: while executing gem .. (Errno::EINVAL)
Invalid argument - ./</cdesc-<.yaml

I'm running Rails on Vista, and I'm also a newbie. Any ideas on how to fix this?

Missing nifty_authentication generator

I installed nifty-generators on Ubuntu 8.10, ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux], gem 1.3.4, but nifty_authentication generator is missing.

Effect vs affect

In line 32 of file rails_generators/nifty_scaffold/USAGE, using the word 'affect', instead of 'effect', might be more appropriate.

yield(:title) || "Untitled." Doesn't work on rails 3.

If you are experiencing this issue, it may have to do with the changes on how rails handles view helpers.

yield(:title) never returns nil anymore, it will always return "", which is nil.to_s.

With that said, the OR syntax ( || ) won't work.

I had to refactor it to work as expected with a change.

Usage in layouts.

ex: <title>Awesomeness :: <%= default_title "Welcome to my awesome site" %></title>

Usage in views.

ex: <% title "Have a look at our services" %>

module LayoutHelper
  def default_title(default_title)
    content_for?(:title) ? content_for(:title) : default_title
  end

  def title(page_title)
    content_for(:title) { page_title.to_s }
  end
end

controller in namespace

It would be a very appreciated feature (at least by myself) if the nifty_scaffold generator could create a controller in a namespace.
Things to add:

  • namespace name:: before controller name in controller declaration and in spec files
  • replace @object with [:namespace, @object] in link_to stuff
  • create directories for namespaces in controllers, views, spec (?)

What do you think ?

Specs out of date

Hi, great gem - thanks! The specs do not work in Rspec 1.2.9 - for one reason at least, any_instance is no longer supported. Being that Rspec has it's own scaffold specs now, it would be great to just use those. If I get a second, I'll do a fork.

  • Sean

Rails3: Nifty:Authentication Uninitialized Constant

Fresh application, ran:
rails g nifty:layout
rails g nifty:authentication

Starting up the application and navigating to localhost:3000/users/new it gives the error:
"uninitialized constant ApplicationController::Authentication"

When I went in and started fiddling with the application_controller.rb changed the line:
include Authentication
to
require "authentication" #I'm kind of a newb
the page comes up, so I added a line to new.html.erb:
<%= logged_in? %>
and it throws an error for no function logged_in? being defined.

Then I changed the require statement back to:
include Authentication

and the page loads fine.

Then, when I restart the server, I get the uninitialized constant error again, and have to go through all these steps again.

Is this a rails issue with not loading modules correctly?
For the time being I guess I'll just copy/paste the methods into the application_controller.rb file like I had been doing before using nifty:authentication.

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.