Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion guides/source/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ of the files and folders that Rails created by default:
| File/Folder | Purpose |
| ----------- | ------- |
|app/|Contains the controllers, models, views, helpers, mailers and assets for your application. You'll focus on this folder for the remainder of this guide.|
|bin/|Contains the rails script that starts your app and can contain other scripts you use to deploy or run your application.|
|bin/|Contains the rails script that starts your app and can contain other scripts you use to setup, deploy or run your application.|
|config/|Configure your application's routes, database, and more. This is covered in more detail in [Configuring Rails Applications](configuring.html).|
|config.ru|Rack configuration for Rack based servers used to start the application.|
|db/|Contains your current database schema, as well as the database migrations.|
Expand Down
4 changes: 4 additions & 0 deletions railties/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* Add `bin/setup` script to bootstrap an application.

*Yves Senn*

* Replace double quotes with single quotes while adding an entry into Gemfile.

*Alexander Belaev*
Expand Down
28 changes: 28 additions & 0 deletions railties/lib/rails/generators/rails/app/templates/bin/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
require 'pathname'

# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)

Dir.chdir APP_ROOT do
# This script is a starting point to setup your application.
# Add necessary setup steps to this file:

puts "== Installing dependencies =="
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before even this, we should install bundler.

system "gem install bundler --conservative"
system "bundle install"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be worth change this to bundle check || bundle install? Most of our setup scripts are doing this to speed up the setup if the gems are already installed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 will update.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why doesn't bundle install already does this speed up? May worth patching it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


# puts "\n== Copying sample files =="
# unless File.exists?("config/database.yml")
# system "cp config/database.yml.sample config/database.yml"
# end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we wanna include this? at least the apps I worked with 10% of them needed to copy a database.yml.sample , wondering if adding this will make starters life harder?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's commented out as a suggestion. We have some projects where this is needed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I’d kill this. We have the secrets.yml now. So everyone is supposed to checkin database.yml.

On May 22, 2014, at 5:45 PM, Yves Senn notifications@github.com wrote:

In railties/lib/rails/generators/rails/app/templates/bin/setup:

+# path to your application root.
+APP_ROOT = Pathname.new File.expand_path('../../', FILE)
+
+Dir.chdir APP_ROOT do

  • This script is a starting point to setup your application.

  • Add necessary setup steps to this file:

  • puts "== Installing dependencies =="
  • system "gem install bundler --conservative"
  • system "bundle install"
  • puts "\n== Copying sample files =="

  • unless File.exists?("config/database.yml")

  • system "cp config/database.yml.sample config/database.yml"

  • end

It's commented out as a suggestion. We have some projects where this is needed.


Reply to this email directly or view it on GitHub.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copying sample files is not directly related to database.yml. I could change the file name.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could change this to copy a sample of secrets.yml instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’d like to see a realistic example before we include it.

On May 22, 2014, at 6:00 PM, Lucas Mazza notifications@github.com wrote:

In railties/lib/rails/generators/rails/app/templates/bin/setup:

+# path to your application root.
+APP_ROOT = Pathname.new File.expand_path('../../', FILE)
+
+Dir.chdir APP_ROOT do

  • This script is a starting point to setup your application.

  • Add necessary setup steps to this file:

  • puts "== Installing dependencies =="
  • system "gem install bundler --conservative"
  • system "bundle install"
  • puts "\n== Copying sample files =="

  • unless File.exists?("config/database.yml")

  • system "cp config/database.yml.sample config/database.yml"

  • end

We could change this to copy a sample of secrets.yml instead.


Reply to this email directly or view it on GitHub.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

secrets.yml can be checked too. We use sample files a lot but I'd remove it since I believe it is specific of some projects.


puts "\n== Preparing database =="
system "bin/rake db:setup"

puts "\n== Removing old logs and tempfiles =="
system "rm -f log/*"
system "rm -rf tmp/cache"

puts "\n== Restarting application server =="
system "touch tmp/restart.txt"
end
1 change: 1 addition & 0 deletions railties/test/generators/app_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
bin/bundle
bin/rails
bin/rake
bin/setup
config/environments
config/initializers
config/locales
Expand Down