RailsApps / rails_apps_composer

A gem with recipes to create Rails application templates for Rails starter apps.
http://railsapps.github.io/rails_apps_composer/
1.42k stars 306 forks source link

[Feature Request] rails_admin recipe #127

Open marcamillion opened 11 years ago

marcamillion commented 11 years ago

I am looking for a variety of recipes, and would love to see a list of recipes that other people have created.

Is that available anywhere?

I am really looking for a recipe that includes 'Rails Admin' - https://github.com/sferik/rails_admin

Do you know of any recipes that includes that?

I know this is not an 'issue', but I figured this may be something that others may be interested in.

P.S. If there is no Rails Admin recipe, and I create one, it would be good to be able to contribute it somewhere so others can improve on it and perhaps add their own.

DanielKehoe commented 11 years ago

So far, no one has contributed any new recipes. As soon as I get a pull request for a new recipe, I'll add it to the recipes directory. I'd be happy to have you create a recipe for rails_admin.

As a model, there's a rails_admin recipe from Dr Nic's AppScrolls project: https://github.com/drnic/appscrolls/blob/master/scrolls/rails_admin.rb It's very simple. The challenge is integrating it with Devise and Cancan (which the AppScroll recipe doesn't attempt).

There's also the RailsWizard recipe but it may be outdated: https://github.com/intridea/rails_wizard/blob/master/recipes/rails_admin.rb

I'd like to see a generalized "admin" recipe that gives a choice of rails_admin or active_admin. And performs any needed integration with Devise and Cancan.

marcamillion commented 11 years ago

Thanks for those links. I will look into it and see what I can come up with.

First, I need to understand how Recipes work and what I need to know to be able to create one. If I have any questions, I will update this issue.

DanielKehoe commented 11 years ago

The Guide goes into detail so make sure to review that carefully.

marcamillion commented 11 years ago

Yep, will do. Thnx!

marcamillion commented 11 years ago

Daniel, Forgive this "noobie" question, but this is the first time I am trying to contribute to a project of this size.

I cloned the project locally, but I also installed rails_app_composer in my ruby environment by running sudo gem install rails_apps_composer. How do I generate a new app from the local repo I have, and not the gem I installed?

Also...this is the process I am thinking of, for implementing this admin functionality.

Does that approach sound fine?

Any gotchas I should be looking out for, or files I should make sure to modify, etc.? Or should that give me a good start and trial and error take me the rest of the way?

DanielKehoe commented 11 years ago

Happy to help you get past noobie status :-)

The Guide contains details in the "Hacking the Gem" section: http://railsapps.github.com/tutorial-rails-apps-composer.html#Hacking

Let me know if I need to clarify anything.

Your approach as described is right on.

You are well on your way.

-- Daniel

marcamillion commented 11 years ago

Perfect...that's just what I need...I missed that somehow :)

DanielKehoe commented 11 years ago

No problem. The Guide is long and dense.

marcamillion commented 11 years ago

There is one thing I am a bit unsure about how to tackle. In the Rails Admin gem, after it is installed and the generator is run, the instructions say that it will install Devise:

This generator will install RailsAdmin and Devise if you don't already have it installed. Devise is strongly recommended to protect your data from anonymous users. Note: If you do not already have Devise installed, make sure you remove the registerable module from the generated user model.

Given that Devise is one option in the Rails Apps Composer, that's not a problem for recipes that involve Devise. But what about those that don't want it, or want OmniAuth for instance.

How should that be handled?

What I was thinking of doing is creating an admin_cpanel preference in the quiz, and if it is chosen go from there. But given this quirk with Devise, I am not quite sure how to proceed.

Thoughts?

DanielKehoe commented 11 years ago

You could add this to the setup.rb recipe:

## Admin Panel
if prefer :authentication, 'devise'
  prefs[:admin_panel] = multiple_choice "Install an admin interface?", [["None", "none"], ["Rails Admin", "rails_admin"], 
    ["Active Admin", "active_admin"]] unless prefs.has_key? :admin_panel
end
marcamillion commented 11 years ago

Ok...That makes sense. So we are only presenting them with the option, if they chose devise. Cool.

marcamillion commented 11 years ago

So I made the changes to the various files, and am running rails_apps_composer for the first time using my locally installed gem, via rails_apps_composer new myapp and this is the list of recipes available to me:

Available Recipes:
apps: prelaunch
collections: core
configuration: email, gems, git, railsapps, readme, setup
example: example
frontend: frontend
initialize: init
mvc: controllers, models, routes, views
other: extras
testing: testing

Where can I modify this list?

I created a recipe called admin.rb - and I modified setup.rb, railsapps.rb & gems.rb.

I never got the prompt that let's me step through all the gems I want to include and setup - like Twitter Bootstrap vs Skeleton, or Devise or Omniauth, etc.

What am I doing wrong?

marcamillion commented 11 years ago

By the way, so I tried going through it with just the core recipes - i.e. after the prompt about ActiveRecord, I just wrote core - when it asks me which recipes I want to use, and I am getting this error message:

Your bundle is updated! Use 'bundle show [gemname]' to see where a bundled gem is installed.
     initializer    generators.rb
  composer  WOOT! The recipes you've selected are known to work together.
  composer  Using rails_apps_composer recipes to generate an application.
  insert    config/application.rb
  recipe  Running core recipe...
    core  selected all core recipes
  recipe  Running git recipe...
     git  initialize git
  remove    .gitignore
 /ruby-1.9.3-p194/lib/ruby/1.9.1/net/http.rb:799:in 'connect': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError)
 /ruby-1.9.3-p194/lib/ruby/1.9.1/net/http.rb:799:in 'block in connect'
 /ruby-1.9.3-p194/lib/ruby/1.9.1/timeout.rb:54:in 'timeout'
 /ruby-1.9.3-p194/lib/ruby/1.9.1/timeout.rb:99:in 'timeout'
 /ruby-1.9.3-p194/lib/ruby/1.9.1/net/http.rb:799:in 'connect'
 /ruby-1.9.3-p194/lib/ruby/1.9.1/net/http.rb:755:in 'do_start'
 /ruby-1.9.3-p194/lib/ruby/1.9.1/net/http.rb:744:in 'start'
 /ruby-1.9.3-p194/lib/ruby/1.9.1/open-uri.rb:306:in 'open_http'
 /ruby-1.9.3-p194/lib/ruby/1.9.1/open-uri.rb:775:in 'buffer_open'
 /ruby-1.9.3-p194/lib/ruby/1.9.1/open-uri.rb:203:in 'block in open_loop'
 /ruby-1.9.3-p194/lib/ruby/1.9.1/open-uri.rb:201:in 'catch'
 /ruby-1.9.3-p194/lib/ruby/1.9.1/open-uri.rb:201:in 'open_loop'
 /ruby-1.9.3-p194/lib/ruby/1.9.1/open-uri.rb:146:in 'open_uri'
 /ruby-1.9.3-p194/lib/ruby/1.9.1/open-uri.rb:677:in 'open'
 /ruby-1.9.3-p194/lib/ruby/1.9.1/open-uri.rb:33:in 'open'
 /ruby-1.9.3-p194/gems/thor-0.16.0/lib/thor/actions/file_manipulation.rb:77:in 'get'
from /var/folders/0f/hgplttnd7dg6q9m62qtbnpn00000gn/T/template20121017-77339-1rhgkp7:93:in 'copy_from'
from /var/folders/0f/hgplttnd7dg6q9m62qtbnpn00000gn/T/template20121017-77339-1rhgkp7:216:in 'apply'
from /ruby-1.9.3-p194/gems/thor-0.16.0/lib/thor/actions.rb:221:in 'instance_eval'
from /ruby-1.9.3-p194/gems/thor-0.16.0/lib/thor/actions.rb:221:in 'apply'
from /ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/generators/app_base.rb:109:in 'apply_rails_template'
from (eval):1:in 'apply_rails_template'
from /ruby-1.9.3-p194/gems/thor-0.16.0/lib/thor/task.rb:27:in 'run'
from /ruby-1.9.3-p194/gems/thor-0.16.0/lib/thor/invocation.rb:120:in 'invoke_task'
from /ruby-1.9.3-p194/gems/thor-0.16.0/lib/thor/invocation.rb:126:in 'block in invoke_all'
from /ruby-1.9.3-p194/gems/thor-0.16.0/lib/thor/invocation.rb:126:in 'each'
from /ruby-1.9.3-p194/gems/thor-0.16.0/lib/thor/invocation.rb:126:in 'map'
from /ruby-1.9.3-p194/gems/thor-0.16.0/lib/thor/invocation.rb:126:in 'invoke_all'
from /ruby-1.9.3-p194/gems/thor-0.16.0/lib/thor/group.rb:238:in 'dispatch'
from /ruby-1.9.3-p194/gems/thor-0.16.0/lib/thor/base.rb:425:in 'start'
from /ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands/application.rb:38:in '<top (required)>'
from /ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in 'require'
from /ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in 'require'
from /ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/cli.rb:15:in '<top (required)>'
from /ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in 'require'
from /ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in 'require'
from /ruby-1.9.3-p194/gems/rails-3.1.3/bin/rails:7:in '<top (required)>'
from /ruby-1.9.3-p194/bin/rails:19:in 'load'
from /ruby-1.9.3-p194/bin/rails:19:in '<main>'
from /ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in 'eval'
from /ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in '<main>'
DanielKehoe commented 11 years ago

Looks like several things are happening. First there is an SSL failure, See this article: http://railsapps.github.com/openssl-certificate-verify-failed.html

Second if the new recipe does not show up in the list of available recipes, I'd guess you did not compile and install the new version of the gem. Did you run "rake reinstall"?

marcamillion commented 11 years ago

I did find that post on the SSL cert, and am no longer getting that SSL error.

Yes I ran rake reinstall - this is the result:

$ rake reinstall
rm -r dist
mkdir -p dist/
gem build rails_apps_composer.gemspec
  Successfully built RubyGem
  Name: rails_apps_composer
  Version: 2.2.15
  File: rails_apps_composer-2.2.15.gem
mv rails_apps_composer-2.2.15.gem dist/rails_apps_composer-2.2.15.gem
gem install dist/rails_apps_composer-2.2.15.gem
Successfully installed rails_apps_composer-2.2.15
1 gem installed
Installing ri documentation for rails_apps_composer-2.2.15...
Installing RDoc documentation for rails_apps_composer-2.2.15...
Installed new rails_apps_composer 2.2.15

The issue I am having now is, I just did rails_apps_composer new myapp and it is taking me through the process, but I am not seeing my recipe show up in the list.

This is what I am seeing:

recipe  Running railsapps recipe...
    question  Install an example application?
        1)  I want to build my own application
        2)  rails3-bootstrap-devise-cancan
        3)  rails3-devise-rspec-cucumber
        4)  rails3-mongoid-devise
        5)  rails3-mongoid-omniauth
        6)  rails3-subdomains
  railsapps  Enter your selection: 

This is the prefs[:railsapp] definition at the top of my railsapps.rb file:

  prefs[:railsapps] = multiple_choice "Install an example application?", 
    [["I want to build my own application", "none"], 
    ["rails3-bootstrap-devise-cancan", "rails3-bootstrap-devise-cancan"], 
    ["rails3-bootstrap-devise-cancan-rails_admin", "rails3-bootstrap-devise-cancan-rails_admin"], 
    ["rails3-devise-rspec-cucumber", "rails3-devise-rspec-cucumber"], 
    ["rails3-mongoid-devise", "rails3-mongoid-devise"],
    ["rails3-mongoid-omniauth", "rails3-mongoid-omniauth"],
    ["rails3-subdomains", "rails3-subdomains"]] unless prefs.has_key? :railsapps

How is the menu, at the command prompt, generated? I assumed it was from this attribute....but doesn't seem to be working for me.

Edit: Yes, I did add the respective case options for rails3-bootstrap-devise-cancan-rails_admin...which looks like this:

when 'rails3-bootstrap-devise-cancan-rails_admin'
  prefs[:git] = true
  prefs[:database] = 'sqlite'
  prefs[:unit_test] = 'rspec'
  prefs[:integration] = 'cucumber'
  prefs[:fixtures] = 'factory_girl'
  prefs[:frontend] = 'bootstrap'
  prefs[:bootstrap] = 'sass'
  prefs[:email] = 'gmail'
  prefs[:authentication] = 'devise'
  prefs[:devise_modules] = 'default'
  prefs[:authorization] = 'cancan'
    prefs[:admin_panel] = 'rails_admin'
  prefs[:starter_app] = 'admin_app'
  prefs[:form_builder] = 'simple_form'
  prefs[:quiet_assets] = true
DanielKehoe commented 11 years ago

What happens if you try rails_apps_composer new myapp -r admin ?

lastobelus commented 11 years ago

I am working on a recipe for active_admin, and would be happy to make it generic and give the option of active_admin or rails_admin. It will also include integration with Zurb foundation.

BUT I'm going to get running of single recipes on an existing app working first. Because otherwise the time to iterate through testing and fixing recipes is too onerous for my ADHD brain.

marcamillion commented 11 years ago

Daniel, I get this:

$ rails_apps_composer new myadmin -r admin
Would you like to skip Test::Unit? (yes for RSpec) (y/n) y
Would you like to skip Active Record? (yes for MongoDB) (y/n) n
What gem would you like to add? (blank to finish) 
> No recipe found with name 'admin'.
DanielKehoe commented 11 years ago

@lastobelus Looking forward to seeing what you've done.

@marcamillion I am traveling for a few days without a work computer so I can't look closely at your situation. It seems the admin.rb recipe is not compiled into the gem. I advise to take a closer look at how you are building and installing the gem. Look closely at the gem environment. When you run rails_apps_composer, which version of the gem is actually running? When you run rake reinstall, are you actually replacing the gem you used? Are you using the same rvm gemset? I like to use one rvm gemset to build the gem and then install it into a different gemset to test it.

AJ-Acevedo commented 11 years ago

+1 on the rails_admin or active_admin recipe!