-
Notifications
You must be signed in to change notification settings - Fork 282
Add ability to namespace a resource for nifty:scaffold #63
base: master
Are you sure you want to change the base?
Conversation
Thank you for your work on this Doug, sorry for not getting back to you sooner on this. It is something that I have been meaning to add to Nifty Generators but never got to it. One thing I am unsure about is whether the model should have a namespace. I realize this is how the built in Rails scaffold generator works but imagine you are creating an administration interface for models. The models should often be at the base layer without a namespace. What do you think? I'm adding a discuss label to this to get some feedback from others as well. Your solution looks very clean and simpler than I had expected, nice job. |
Ryan- I did think about the model namespacing, especially when the issue with the database table name came around; I figured in most cases, you would want to skip the model (with --skip-model). Say you already built a scaffold for Contacts, if you wanted to create an admin interface, you wouldn't create a new Admin::Contact model. I imagine this would be more common than a case where you wouldn't have an existing model and would not want it namespaced. Also; with this approach, you can skip the model and build it with another generator; with the other approach, if you wanted one, you wouldn't be able to generate a namespaced model. Thanks again for going over this. Let me know what you think, |
The only problem with the Maybe add a |
Actually I take that back, it isn't necessary to have the model namespace in the controller since Ruby will find it in the same namespace by default. I would still like no model namespace as the default behavior though, so an option might still be necessary? |
In the latest intermediate commit (DouglasMeyer@eb12c149f2d), I'm seeing a weird issue. It looks like, in the Admin::UserController, the User model isn't getting loaded. Running the features should show this. So it looks like we may have to explicitly reference Admin::User to get to the model, when using the --namespace-model option. Otherwise, it should be functional. |
Thanks Douglas. Once you get this working I'll pull it in. |
Hey Ryan- it's working!! DouglasMeyer@7dabe270bd Thanks for following the progress on this. |
Thanks for your work on this. I will try to get it pulled in soon. |
Ryan - Please let us know when you incorporate this. Ive been waiting for this for a LONG time :) |
This is pulled in now and will be in a version release soon. Thanks Doug! |
Your welcome. Glad I was able to help. |
… =. (app/views/sessions/new.html.haml:5)
…nto nhocki-master
Great stuff. I tried the following with Rails 2.3.11 and get the following result. Thanks, Tom |
Hey Tom & Ryan- Sorry, oversight my me. I assume nifty-generators still supports rails 2 to some extent, so I'll see if I can get that working as well. Let me know if that is not the case. |
I am not planning on adding new features to the Rails 2 version of Nifty Generators. Partly because the tests are a mess. Doug, if you want to figure it out and make sure it's fully tested I will pull it in. But if you aren't up for it then don't worry. |
Hey Tom- Let me know if it looks like anything is missing, |
@DouglasMeyer Thanks for your work on this, I'll get it pulled in soon. |
I tried this, and seems to work in app. But, while running generated specs, I get: /media/code/test/spec/controllers/articles/posts_controller_spec.rb:1:in `require': no such file to load -- /media/code/test/spec/controllers/articles/../spec_helper (LoadError) I generated it with: |
Also, running cucumber tests gets me https://gist.github.com/1033291 |
and it would be great if created table was articles_posts, not posts (in my example above) :) |
Hey Matija- Hey Ryan- |
@DouglasMeyer are you running the specs for the Rails 2 generator? Those are terribly broken. I am surprised you can get them to run at all actually, which is one reason I have not changed the Rails 2 generators much. I think I will discontinue Rails 2 support after this latest feature is in. Thanks for your work on it. |
@ryanb Oddly enough, I didn't have many issues running |
Yeah, that is the plan. It is probably best to test Rails 2 additions manually for now, I don't trust the test suite that's in there for that. Once this release is done I will remove the Rails 2 support and only update it for minor bug fixes. |
Bump! Would love to see this in nifty... |
Hey Ryan-
This is in response to issue #7
Hopefully the "feature" test will show what this is trying to accomplish. So far, it only works in rails 3; I just found-out how to run the tests for rails 2. Could you let me know if this patch would be something you're interested in, or what you would like to see changed to make it acceptable?
Thanks,
-Doug