Created
February 3, 2011 19:39
-
-
Save mhinton/810032 to your computer and use it in GitHub Desktop.
this is a basic rails 3 app template
This file contains 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
rvmrc = <<-RVMRC | |
rvm gemset use #{app_name} | |
RVMRC | |
create_file ".rvmrc", rvmrc | |
gem "devise" | |
gem "formtastic", '~> 1.2.3' | |
gem "client_side_validations" | |
gem "factory_girl_rails", ">= 1.0.0", :group => :test | |
gem "factory_girl_generator", ">= 0.0.1", :group => [:development, :test] | |
gem "rspec-rails", ">= 2.0.1", :group => [:development, :test] | |
gem "shoulda", :group => :test | |
generators = <<-GENERATORS | |
config.generators do |g| | |
g.test_framework :rspec, :fixture => true, :views => false | |
g.integration_tool :rspec, :fixture => true, :views => true | |
end | |
GENERATORS | |
application generators | |
get "http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js", "public/javascripts/jquery.js" | |
get "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/jquery-ui.min.js", "public/javascripts/jquery-ui.js" | |
get "https://github.com/rails/jquery-ujs/raw/master/src/rails.js", "public/javascripts/rails.js" | |
gsub_file 'config/application.rb', 'config.action_view.javascript_expansions[:defaults] = %w()', 'config.action_view.javascript_expansions[:defaults] = %w(jquery.js jquery-ui.js rails.js)' | |
layout = <<-LAYOUT | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset=utf-8> | |
<title><%= #{app_name.humanize} -%></title> | |
<%= stylesheet_link_tag :all %> | |
<%= stylesheet_link_tag 'formtastic', 'formtastic_changes' %> | |
<%= javascript_include_tag 'jquery', 'jquery-ui', 'rails', 'rails.validations', 'application' %> | |
<%= csrf_meta_tag %> | |
</head> | |
<body> | |
<header> | |
</header> | |
<nav> | |
</nav> | |
<section id="content"> | |
<%= yield %> | |
</section> | |
<footer> | |
</footer> | |
</body> | |
</html> | |
LAYOUT | |
remove_file "app/views/layouts/application.html.erb" | |
create_file "app/views/layouts/application.html.erb", layout | |
create_file "log/.gitkeep" | |
create_file "tmp/.gitkeep" | |
git :init | |
git :add => "." | |
docs = <<-DOCS | |
Run the following commands to complete the setup of #{app_name.humanize}: | |
% rvm gemset create #{app_name} | |
% cd #{app_name} | |
% gem install bundler | |
% bundle install | |
% script/rails generate rspec:install | |
% rails generate devise:install | |
% rails generate client_side_validations:install | |
% rails generate formtastic:install | |
% rails generate devise User | |
% rails generate devise:views | |
# class User < ActiveRecord::Base | |
# devise :database_authenticatable, :confirmable, :recoverable, :rememberable, :trackable, :validatable | |
# end | |
# create_table :users do |t| | |
# t.database_authenticatable | |
# t.confirmable | |
# t.recoverable | |
# t.rememberable | |
# t.trackable | |
# t.timestamps | |
# end | |
add the following to the routes file | |
devise_for :users | |
Set up a controller with user authentication, just add this before_filter: before_filter :authenticate_user! | |
To verify if a user is signed in, use the following helper: user_signed_in? | |
For the current signed-in user, this helper is available: current_user | |
You can access the session for this scope: user_session | |
Finally, you need to set up default url options for the mailer in each environment. Here is the configuration for config/environments/development.rb: config.action_mailer.default_url_options = { :host => 'localhost:3000' } | |
DOCS | |
log docs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment