Last active
January 2, 2016 06:29
-
-
Save leonardteo/8263273 to your computer and use it in GitHub Desktop.
Rails Application Template with Endless Gem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Endless Rails application template | |
# For use with v1.0.3 | |
# | |
# This should be copied to https://gist.github.com/leonardteo/8263273 | |
# | |
# Usage: | |
# rails new [app name] -m https://gist.github.com/leonardteo/8263273/raw/endless-app-template.rb | |
# Front-end gems | |
gem 'slim' | |
gem 'jquery-ui-rails' | |
gem 'simple_form' | |
gem 'devise' | |
gem 'endless', git: '[email protected]:ballistiq/endless.git', branch: 'master' | |
# Everything else that you'll probably need | |
gem 'capistrano', group: :development | |
gem 'configatron' | |
gem 'whenever' | |
gem 'paperclip' | |
gem 'factory_girl' | |
gem 'pry-rails' | |
gem 'thin' | |
run "bundle install" | |
insert_into_file "app/assets/javascripts/application.js", "//= require jquery.ui.all\n//= require endless/endless_libs\n//= require endless\n", :after => "jquery_ujs\n" | |
# Run Endless generators | |
run "rails g endless:install" | |
run "rails g endless:layout" | |
run "rails g devise:install" | |
run "rails g scaffold User first_name last_name" | |
run "rails g devise User" | |
run "rails g endless:devise" | |
# Update configs | |
application "config.to_prepare { Devise::SessionsController.layout proc{ |controller| action_name == 'new' ? 'devise' : 'application' } }" | |
# Pretty slim templates | |
initializer 'slim.rb', <<-CODE | |
Slim::Engine.set_default_options pretty: true, sort_attrs: false | |
CODE | |
# Set up devise to allow additional attributes | |
insert_into_file "app/controllers/application_controller.rb", :before => "end" do |app_controller| | |
<<-CODE | |
before_filter :configure_permitted_parameters, if: :devise_controller? | |
protected | |
def configure_permitted_parameters | |
devise_parameter_sanitizer.for(:sign_up) << :first_name << :last_name | |
end | |
CODE | |
end | |
# Update registration form | |
remove_file "app/views/devise/registrations/new.html.slim" | |
create_file "app/views/devise/registrations/new.html.slim" do |registration_view| | |
<<-CODE | |
.login-wrapper | |
.text-center | |
h1 Sign up | |
p Please register below | |
.login-widget.animation-delay1 | |
.panel.panel-default | |
.panel-body | |
= bootstrap_flash :class => "alert-margin-bottom" | |
= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| | |
= f.input :first_name, :autofocus => true | |
= f.input :last_name | |
= f.input :email, :required => true | |
= f.input :password, :required => true | |
= f.input :password_confirmation, :required => true | |
= f.button :submit, "Sign up", :class => "btn-info" | |
.seperator | |
= render "devise/shared/links" | |
CODE | |
end | |
# Create a Dashboard | |
run "rails g controller dashboard index" | |
route "root 'dashboard#index'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment