Commit Graph

149 Commits

Author SHA1 Message Date
Kasper Timm Hansen
43dd8478b4
Fix routes command tests broken in e137831726. 2018-03-04 20:47:35 +01:00
Genadi Samokovarov
5af643d8d6 Introduce explicit rails server handler option
I mistype `rails server production` instead of `rails server -e
production` expecting to lunch a server in the production environment
all the time. However, the signature of `rails server --help` is:

```
Usage:
  rails server [puma, thin etc] [options]
```

This means that the `production` argument is being interpreted as a Rack
server handler like Puma, Thin or Unicorn.

Should we argue for the `rails server production`? I'm not sure of the
reasons, but the `rails console production` behavior was deprecated in:
https://github.com/rails/rails/pull/29358, so parity with the existing
`rails console production` usage may not hold anymore.

In any case, this PR introduces an explicit option for the Rack servers
configuration. The option is called `--using` (or `-u` for short) to
avoid the `rails server --server` tantrum.

The new interface of `rails server` is:

```
Usage:
  rails server [using] [options]

Options:
  -p, [--port=port]                        # Runs Rails on the specified port - defaults to 3000.
  -b, [--binding=IP]                       # Binds Rails to the specified IP - defaults to 'localhost' in development and '0.0.0.0' in other environments'.
  -c, [--config=file]                      # Uses a custom rackup configuration.
                                           # Default: config.ru
  -d, [--daemon], [--no-daemon]            # Runs server as a Daemon.
  -e, [--environment=name]                 # Specifies the environment to run this server under (development/test/production).
  -u, [--using=name]                       # Specifies the Rack server used to run the application (thin/puma/webrick).
  -P, [--pid=PID]                          # Specifies the PID file.
                                           # Default: tmp/pids/server.pid
  -C, [--dev-caching], [--no-dev-caching]  # Specifies whether to perform caching in development.
      [--early-hints], [--no-early-hints]  # Enables HTTP/2 early hints.
```

As a bonus, if you mistype the server to use, you'll get an
auto-correction message:

```
$ rails s tin
Could not find handler "tin". Maybe you meant "thin" or "cgi"?
Run `rails server --help` for more options.
```
2018-03-04 17:50:29 +02:00
yuuji.yaginuma
90de2dc6f2 Clean up RoutesTest a bit
* Remove unused require
* Remove redundant `test`
* Change `rake` to `rails`
2018-03-01 20:44:05 +09:00
Benoit Tigeot
c6d928f3ca Add --expanded option to "rails routes"
When using rails routes with small terminal or complicated routes it can be
very difficult to understand where is the element listed in header. psql
had the same issue, that's why they created "expanded mode" you can
switch using `\x` or by starting psql with
```
-x
--expanded

    Turn on the expanded table formatting mode. This is equivalent to the \x command.
```
The output is similar to one implemented here for rails routes:

db_user-# \du
List of roles
-[ RECORD 1 ]----------------------------------------------
Role name  | super
Attributes | Superuser, Create role, Create DB
Member of  | {}
-[ RECORD 2 ]----------------------------------------------
Role name  | role
Attributes | Superuser, Create role, Create DB, Replication
Member of  | {}
2018-02-28 22:32:34 +01:00
Benoit Tigeot
a2748eda58 Move rake routes task to rails command
After a discussion with matthewd. It was mentioned that rake tasks need
to be moved to rails command.
See: https://github.com/rails/rails/issues/32117
2018-02-27 15:22:38 +01:00
Yuji Yaginuma
5d75ef72e6
Do not add master key when RAILS_MASTER_KEY env specified (#31922)
Fixes #31917
2018-02-08 19:49:50 +09:00
Daniel Colson
94333a4c31 Use assert_predicate and assert_not_predicate 2018-01-25 23:32:59 -05:00
yuuji.yaginuma
35373219c9 Raise an error only when require_master_key is specified
To prevent errors from being raise in environments where credentials
is unnecessary.

Context: https://github.com/rails/rails/issues/31283#issuecomment-348801489

Fixes #31283
2017-12-18 08:04:15 +09:00
yuuji.yaginuma
f7e3c68668 Do not overwrite by default if credentials already exists
Fixes #31286
2017-11-30 10:15:45 +09:00
Wojciech Wnętrzak
7a8728a039
Add CLI to manage encrypted files/configs.
To edit/show encrypted file:

```
bin/rails encrypted:edit config/staging_tokens.yml.enc
bin/rails encrypted:edit config/staging_tokens.yml.enc --key config/staging.key
bin/rails encrypted:show config/staging_tokens.yml.enc
```

Also provides a backing Rails.application.encrypted API for Ruby access:

```ruby
Rails.application.encrypted("config/staging_tokens.yml.enc").read
Rails.application.encrypted("config/staging_tokens.yml.enc").config
Rails.application.encrypted("config/staging_tokens.yml.enc", key: "config/staging.key")
```
2017-11-15 21:29:15 +01:00
Kasper Timm Hansen
bb30f05f38
Deprecate encrypted secrets in favor of credentials.
Allow edits of existing encrypted secrets generated on Rails 5.1,
but refer to credentials when attempting to setup.

This also removes the need for any of the setup code, so the
generator can be ripped out altogether.
2017-11-12 17:50:09 +01:00
yuuji.yaginuma
6a7559417f Fix test name for daemon option test
In this test file, "server option" refers to the server used to start
Rails(e.g. `puma`, `thin`).
But this test, "server option" is not specified. Therefore, I think that
it is incorrect that `server_option` is included in the test name.
2017-10-14 07:34:33 +09:00
Pierre Hedkvist
edf167e848 Added test case for starting rails with daemon option, this should set the option[:daemonize] to true, otherwise the option[:daemonize] will be set to false 2017-10-13 13:21:11 +00:00
yuuji.yaginuma
c4bbce9697 Simplify parse arguments in ConsoleTest
If need a parse result of arguments, can obtain it by creating
an instance of the command.
2017-10-08 13:12:49 +09:00
eileencodes
59a02fb7bc Implement H2 Early Hints for Rails
When puma/puma#1403 is merged Puma will support the Early Hints status
code for sending assets before a request has finished.

While the Early Hints spec is still in draft, this PR prepares Rails to
allowing this status code.

If the proxy server supports Early Hints, it will send H2 pushes to the
client.

This PR adds a method for setting Early Hints Link headers via Rails,
and also automatically sends Early Hints if supported from the
`stylesheet_link_tag` and the `javascript_include_tag`.

Once puma supports Early Hints the `--early-hints` argument can be
passed to the server to enable this or set in the puma config with
`early_hints(true)`. Note that for Early Hints to work
in the browser the requirements are 1) a proxy that can handle H2,
and 2) HTTPS.

To start the server with Early Hints enabled pass `--early-hints` to
`rails s`.

This has been verified to work with h2o, Puma, and Rails with Chrome.

The commit adds a new option to the rails server to enable early hints
for Puma.

Early Hints spec:
https://tools.ietf.org/html/draft-ietf-httpbis-early-hints-04

[Eileen M. Uchitelle, Aaron Patterson]
2017-10-04 09:17:21 -04:00
yuuji.yaginuma
8a331566bf Add tests for credentials command 2017-09-15 14:31:02 +09:00
yuuji.yaginuma
d5d41c8281 Make master key added to gitignore the same value as when creating appplication
For gitignore generated by `rails new`, key with a leading slash is specified.
69f976b859/railties/lib/rails/generators/rails/app/templates/gitignore (L11)

Therefore, when executing `credentials:edit`, also need leading slack.
In order to avoid such a difference, fixed to use same method for
`rails new` and `credentials:edit`.
2017-09-14 07:17:25 +09:00
Matthew Draper
802ce8a239 Run in-app rails commands via fork+load where possible
While this avoids shell argument parsing, we still pass through
everything in our stack.
2017-09-04 20:19:39 +09:30
yuuji.yaginuma
c3b2d7117c Fix can't modify frozen String error in DBConsole
Without this, `dbconsole` raises an error as follwing:

```
RuntimeError: can't modify frozen String
    railties/lib/rails/commands/dbconsole/dbconsole_command.rb:79:in `start'
```
2017-08-29 16:50:51 +09:00
yuuji.yaginuma
2904ee23bf Make restart and dev:cache tasks work when customizing pid file path
Originally, it hard-coded pid file path. It can not be removed when customizing
pid file path.
But rake task can not get pid file path. Therefore, do not remove file in rake
task, makes it possible to judge whether it is restart from the argument of the
command and removes the file in server command.

Fixes #29306
2017-08-21 05:44:11 +09:00
Pat Allan
acea68de02 Adding frozen_string_literal pragma to Railties. 2017-08-14 19:08:09 +02:00
Robin Dupret
3777701f13 Properly expand the environment's name
Running the `console` and `dbconsole` commands with a regular argument
as the environment's name automatically expand it to match an existing
environment (e.g. dev for development).

This feature wasn't available using the `--environment` (a.k.a `-e`)
option.
2017-07-16 15:10:39 +02:00
Robin Dupret
48b2499273 Deprecate environment as an argument for dbconsole and console
People should rather rely on the `-e` or `--environment` options to
specify in which environment they want to work. This will allow us
to specify the connection to pick as a regular argument in the future.
2017-07-16 15:10:34 +02:00
Robin Dupret
1acd9a6464 Allow to pass a connection to the dbconsole command
Since 0a4f6009, it's possible to specify a 3-level database
configuration to gather connections by environment.

The `dbconsole` command will try to look for a database configuration
which points to the current environment but with such flavour, the
environment key is flushed out so let's add the ability to specify
the connection and pick `primary` by default to be consistent with
Active Record.
2017-07-16 14:39:09 +02:00
yuuji.yaginuma
af5368eeff Add rails secrets:show command
When secrets confirmed with the `secrets:edit` command, `secrets.yml.enc`
will change without updating the secrets.

Therefore, even if only want to check secrets, the difference will come
out. This is a little inconvenient.

In order to solve this problem, added the `secrets:show` command.
If just want to check secrets, no difference will occur use this command.
2017-07-07 07:22:01 +09:00
Matthew Draper
87b3e226d6 Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"
This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing
changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
2017-07-02 02:15:17 +09:30
Kir Shatrov
cfade1ec7e Enforce frozen string in Rubocop 2017-07-01 02:11:03 +03:00
Pavel Valena
edbe7c417a Do not use UTF8 in test SecretsCommandTest#test_edit_secrets 2017-05-30 01:53:31 +02:00
Kasper Timm Hansen
1722304395 Merge pull request #29146 from y-yagi/fix_29138
Correctly set user_supplied_options when there is no whitespace in option specification
2017-05-28 17:19:43 +02:00
Kasper Timm Hansen
0338c81dc2 Reorder first secrets edit flow.
Setup config/secrets.yml.enc with template contents for people to edit.

Then generate encryption key and encrypt the initial secrets.
2017-05-25 15:56:55 +02:00
yuuji.yaginuma
7a154ab380 Correctly set user_supplied_options when there is no whitespace in option specification
Current `user_supplied_options` method can not set the value correctly
if there is no space between option and value (e.g., `-p9000`).
This makes it possible to set the value correctly in the case like the above.

Fixes #29138
2017-05-24 16:11:52 +09:00
koshigoe
c092883169
CLI arg --port has precedence over env PORT. 2017-05-01 21:28:47 +09:00
Jon Moss
d0accc23b3 CLI arg "host" has precedence over ENV var "host"
This is a regression from when the server command switched to its own
argument parser, as opposed to Rack's. Rack's argument parser, when
provided with a "host" argument, gives that value precedence over
environment variables.
2017-03-21 19:07:40 -04:00
yuuji.yaginuma
7b4fb2574a Add secrets edit test 2017-03-12 13:43:58 +09:00
Kasper Timm Hansen
82f7dc6178 Tell users how to assign a $EDITOR.
In case there's no $EDITOR assigned users would see a cryptic:

```
% EDITOR= bin/rails secrets:edit
Waiting for secrets file to be saved. Abort with Ctrl-C.
sh: /var/folders/wd/xnncwqp96rj0v1y2nms64mq80000gn/T/secrets.yml.enc: Permission denied
New secrets encrypted and saved.
```

That error is misleading, so give a hint in this easily detectable case.

Fixes #28143.
2017-03-01 20:44:17 +01:00
yuuji.yaginuma
60aeb6a8f9 Set correct host except development environment
Currently `localhost` is used for the default host in all environments.
But up to Rails 5.0, `0.0.0.0` is used except for development.
So fixed to use the same value as 5.0.

Fixes #28184
2017-02-27 21:32:57 +09:00
schneems
6ac4dabbcf [close #24435] Send user_supplied_options to server
Currently when Puma gets a `:Port` it doesn't know if it is Rails' default port or if it is one that is specified by a user. Because of this it assumes that the port passed in is always a user defined port and therefor 3000 always "wins" even if you specify `port` inside of the `config/puma.rb` file when booting your server with `rails s`.

The fix is to record the options that are explicitly passed in from the user and pass those to the Puma server (or all servers really). Puma then has enough information to know when `:Port` is the default and when it is user defined. I went ahead and did this for all values rails server exposes as server side options for completeness.

The hardest thing was converting the input say `-p` or `--port` into the appropriate "name", in this case `Port`. There may be a more straightforward way to do this with Thor, but I'm not an expert here.

Move logic for parsing user options to method

Better variable name for iteration

Explicitly test `--port` user input

✂️

Update array if environment variables are used
2017-02-24 10:00:29 -06:00
yuuji.yaginuma
f5f834fb34 improve server default options test
This test was added in 221b4ae.
221b4ae modified to return the same result even if `Rails::Server#default_options`
is called more than once. Therefore, also use `Rails::Server#default_options`
instead of `ServerCommand#default_options` in test.
2017-01-09 10:07:53 +09:00
Kasper Timm Hansen
ca3eb2c156 Merge branch 'master' into fix_26964 2016-12-29 20:09:43 +01:00
Akira Matsuda
e8ba0c0f21 "Use assert_nil if expecting nil. This will fail in minitest 6." 2016-12-25 02:29:52 +09:00
yuuji.yaginuma
654704247e use Thor option parser in server commands parse
The `ServerCommand` inherits Thor, but currently does not use Thor
option parser.
Therefore, if leave the argument of Thor as it is, it becomes an error by
the argument checking of Thor.
To avoid it, to use the Thor option parser instead of reimplementing it.

Fixes #26964
2016-12-24 12:08:33 +09:00
Rafael Mendonça França
fe1f4b2ad5
Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
Kasper Timm Hansen
d5457af76f Fix server command tests. 2016-09-25 21:31:46 +02:00
Kasper Timm Hansen
0fd5377a36 Fix dbconsole tests. 2016-09-25 21:31:46 +02:00
Kasper Timm Hansen
efd808755c Fix console tests. 2016-09-25 21:31:45 +02:00
Rafael Mendonça França
55f9b8129a
Add three new rubocop rules
Style/SpaceBeforeBlockBraces
Style/SpaceInsideBlockBraces
Style/SpaceInsideHashLiteralBraces

Fix all violations in the repository.
2016-08-16 04:30:11 -03:00
Ryuta Kamizono
762e3f05f3 Add Style/EmptyLines in .rubocop.yml and remove extra empty lines 2016-08-07 17:50:59 +09:00
Xavier Noria
b326e82dc0 applies remaining conventions across the project 2016-08-06 20:20:22 +02:00
Xavier Noria
80e66cc4d9 normalizes indentation and whitespace across the project 2016-08-06 20:16:27 +02:00
Xavier Noria
783763bde9 applies new string literal convention in railties/test
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 19:16:09 +02:00
Evgeny Vlasenko
e17d7275f4 Use the HOST environment variable for rails server #25677 2016-07-05 00:36:39 +06:00
Prathamesh Sonpatki
9d87ce34f8 Fix rails restart issue with Puma
- We need to pass the restart command to Puma so that it will use it
  while restarting the server.
- Also made sure that all the options passed by user while starting
  the server are used in the generated restart command so that they will
  be used while restarting the server.
- Besides that we need to remove the server.pid file for the previous running
  server because otherwise Rack complains about it's presence.
- We don't care if the server.pid file does not exist. We only want to delete
  it if it exists.
- This also requires some changes on Puma side which are being tracked
  here - https://github.com/puma/puma/pull/936.
- Fixes #23910.
2016-03-30 11:20:15 +05:30
yuuji.yaginuma
173b524cbc changed default value of caching option to nil
The default is that's false, caching even if you do not specify the caching option is determined not to use,
and `tmp/caching-dev.txt` will be deleted.
If it is this, regardless of whether or not there is `tmp/caching-dev.txt`, be sure to order would be necessary to specify the caching option,
I think that in than good to so as not to do anything by default.
2016-03-21 08:13:27 +09:00
Scott Bronson
ba2aea9807 revert dev:cache to rake task, fixes #23410 2016-02-07 14:32:43 -08:00
Tawan Sierek
221b4aead5 Avoid multiple default paths to server.pid file
Fix bug (#22811) that occurs when rails server is started in daemon mode
and optional path to the `server.pid` file is omitted. Store default path
in a constant instead of evaluating it multiple time using `File.expand_path`.

The bug in detail: The server startup procedure crashes, since it tries to
open a file at `/tmp/pids/server.pid` instead of
`<path to project>/tmp/pids/server.pid`. This bug was introduced in 51211a94bd
when Rack was upgraded from version 1.x to 2.x. Since version 2.x,
Rack does not memoize the options hash [1], and as a consequence
`Rails::Server#default_options` will be evaluated multiple times.
The hash returned by `Rails::Server#default_options` holds the default path
to the `server.pid` file. The path is generated with the method
`File.expand_path`. However, the return value of this method depends on the
current working directory [2], which changes once `Process.daemon` is invoked
by `Rack::Server#daemonize_app` and the process is detached from the current
shell.

Close #22811

[1]https://git.io/vzen2
[2]http://ruby-doc.org/core-2.1.5/File.html#method-c-expand_path
2016-01-16 16:16:43 +01:00
Abdelkader Boudih
fb24d0ed6c Remove legacy mysql adapter 2015-12-17 15:54:57 +00:00
Kasper Timm Hansen
2af9c08079 Clarify the need to run command twice.
We had 2 pull requests erronously trying to remove the first command.
Add some comments for clarity.
2015-12-07 20:36:22 +01:00
Chuck Callebs
2ddb599710 Add Rails command infrastructure and encapsulate development caching 2015-12-04 13:15:43 -05:00
David Cornu
306c14c411 Use the PORT environment variable for rails server 2015-08-18 08:43:11 -04:00
Chuck Callebs
a01e58afd9 Add rake dev:cache task to enable dev mode caching.
Taken from @Sonopa's commits on PR #19091.

Add support for dev caching via "rails s" flags.

Implement suggestions from @kaspth.

Remove temporary cache file if server does not have flags.

Break at 80 characters in railties/CHANGELOG.md

Remove ability to disable cache based on server options.

Add more comprehensive options: --dev-caching / --no-dev-caching
2015-08-04 23:41:23 -04:00
Mehmet Emin İNAÇ
117bb54125 Refactor railties console and dbconsole commands
fix minor convention problems
2015-05-10 06:30:26 +03:00
Andrew White
688c0ec264 Remove sqlite support from rails dbconsole
Support for versions of SQLite less than 3 was removed in #6011 as part
of the Rails 4.0 release. Therefore there is no need to have support for
it in the `rails dbconsole` command anymore.
2015-04-22 14:47:13 -04:00
Jeremy Kemper
5154089c18 Revert "Merge pull request #19404 from dmathieu/remove_rack_env"
Preserving RACK_ENV behavior.

This reverts commit 7bdc7635b885e473f6a577264fd8efad1c02174f, reversing
changes made to 45786be516e13d55a1fca9a4abaddd5781209103.
2015-03-20 08:14:11 -07:00
Damien Mathieu
d578cbfb5c don't fallback to RACK_ENV when RAILS_ENV is not present 2015-03-19 10:06:28 +01:00
Rafael Mendonça França
93559da482 Remove debugger support
bebugger doesn't work with Ruby 2.2 so we don't need to support it
anymore
2015-01-04 15:54:22 -03:00
Akira Matsuda
4ded131181 Expectations first 2014-08-28 14:41:00 +09:00
Akira Matsuda
0c885d6818 Reset RACK_ENV after modified in a test case 2014-08-28 14:41:00 +09:00
Rafael Mendonça França
b17330cf39 Remove mocha usage 2014-07-23 19:01:44 -03:00
Rafael Mendonça França
fcc2231a04 Stop using mocha on dbconsole_test 2014-07-15 23:36:45 -03:00
Rafael Mendonça França
a83efa4a1f Stop using mocha on console_test 2014-07-07 23:39:18 -03:00
David Rodríguez de Dios
6fae9ac581 Isolate debugger related code 2014-04-10 16:02:13 +02:00
David Rodríguez de Dios
7901ae13a1 Keep debugger support only for rubies < 2.0.0 2014-04-08 20:55:23 +02:00
schneems
6cc03675d3 Ensure Active Record connection consistency
Currently Active Record can be configured via the environment variable `DATABASE_URL` or by manually injecting a hash of values which is what Rails does, reading in `database.yml` and setting Active Record appropriately. Active Record expects to be able to use `DATABASE_URL` without the use of Rails, and we cannot rip out this functionality without deprecating. This presents a problem though when both config is set, and a `DATABASE_URL` is present. Currently the `DATABASE_URL` should "win" and none of the values in `database.yml` are used. This is somewhat unexpected to me if I were to set values such as `pool` in the `production:` group of `database.yml` they are ignored.

There are many ways that active record initiates a connection today:

- Stand Alone (without rails)
  - `rake db:<tasks>`
  - ActiveRecord.establish_connection
 
- With Rails
  - `rake db:<tasks>`
  - `rails <server> | <console>`
  - `rails dbconsole`


We should make all of these behave exactly the same way. The best way to do this is to put all of this logic in one place so it is guaranteed to be used.

Here is my prosed matrix of how this behavior should work:

```
No database.yml
No DATABASE_URL
=> Error
```

```
database.yml present
No DATABASE_URL
=> Use database.yml configuration
```

```
No database.yml
DATABASE_URL present
=> use DATABASE_URL configuration
```

```
database.yml present
DATABASE_URL present
=> Merged into `url` sub key. If both specify `url` sub key, the `database.yml` `url`
   sub key "wins". If other paramaters `adapter` or `database` are specified in YAML,
   they are discarded as the `url` sub key "wins".
```

### Implementation

Current implementation uses `ActiveRecord::Base.configurations` to resolve and merge all connection information before returning. This is achieved through a utility class: `ActiveRecord::ConnectionHandling::MergeAndResolveDefaultUrlConfig`.

To understand the exact behavior of this class, it is best to review the behavior in activerecord/test/cases/connection_adapters/connection_handler_test.rb though it should match the above proposal.
2014-01-09 16:35:37 -06:00
schneems
a1f9ae5eb8 Fix DB Console tests
The build is broken: https://travis-ci.org/rails/rails/builds/15824530

This commit fixes it.

The problem: Sqlite expects the `database` part to be an absolute path. That prompted this change to be committed to master: fbb79b517f

This change provides correct behavior. Unfortunately tests were introduced in 971d5107cd that were relying on the incorrect behavior. We can avoid the fix by changing to another database url such as `mysql` or `postgresql`

In addition to fixing the failure, the assertions are changed so that the "expected" value comes before "actual" value.
2013-12-21 23:09:01 -05:00
Huiming Teo
971d5107cd fixed rails dbconsole to support ENV['DATABASE_URL']. 2013-12-16 18:31:49 +08:00
Marc Schütz
16c0023a9a Make logging to stdout work again with implicit development env 2013-10-13 19:21:18 +02:00
schneems
5f98bb402b Only output Server logs in Development
Right now when you start a server via `rails s`, the logger gets extended so that it logs to the file system and also to stdout. This extension behavior is not "intelligent" and if the default logger is already set to output to stdout, then the contents will be received twice.

To capture logs in accordance with http://www.12factor.net/logs some platforms require the logs to be sent to standard out. If a logger is set to stdout, and the server is started using `rails server` instead of another method (i.e. `thin start` etc.) then the app will produce double logs.

This PR fixes the issue by only extending the logger to standard out in the development environment. So that in production you don't get double logs like this:

```
ActionView::Template::Error (wrong number of arguments (5 for 4)):
    1: <% lang_index = 0 %>
    2: <div class="row">
    3:   <ul class="nav nav-tabs nav-stacked span2" data-tabs="tabs" id="repo-tabs">
    4:     <% repos.group_by(&:language).each do |lang, repos| %>
    5:       <% unless lang == nil %>
    6:         <li><a href="#<%= "#{lang.parameterize}#{lang.hash}" %>" data-toggle="tab"><%= lang %></a></li>
    7:       <% end -%>
  app/views/shared/_repos.html.erb:4:in `_app_views_shared__repos_html_erb___1685450633638247395_70300668607000'
  app/views/pages/index.html.erb:13:in `_app_views_pages_index_html_erb__2084723628308867770_70300687584880'

ActionView::Template::Error (wrong number of arguments (5 for 4)):
    1: <% lang_index = 0 %>
    2: <div class="row">
    3:   <ul class="nav nav-tabs nav-stacked span2" data-tabs="tabs" id="repo-tabs">
    4:     <% repos.group_by(&:language).each do |lang, repos| %>
    5:       <% unless lang == nil %>
    6:         <li><a href="#<%= "#{lang.parameterize}#{lang.hash}" %>" data-toggle="tab"><%= lang %></a></li>
    7:       <% end -%>
  app/views/shared/_repos.html.erb:4:in `_app_views_shared__repos_html_erb___1685450633638247395_70300668607000'
  app/views/pages/index.html.erb:13:in `_app_views_pages_index_html_erb__2084723628308867770_70300687584880'
```

ATP Railties. Opened against master in favor of #10999
2013-09-22 20:56:31 -05:00
Vipul A M
113e39625b fix private attribute warning 2013-04-04 23:23:46 +05:30
Carlos Antonio da Silva
11dd15a5c2 Fix failing test regarding console change to fix sandboxing
Introduced in be3e10cd26bc8ec29c6474d03a08a8e733108e7d.
2013-03-08 21:48:28 -03:00
Mykola Kyryk
4fa6088b42 This commit fixes issue #8628
Allow environment name to start with a substring of the default
environment names.
For example: tes, pro, prod, dev, devel, etc.

Fixing identation.

Adding test for Rails::Console.parse_arguments method.

Fix issue 8628 for Rails::DBConsole.
2013-01-04 17:05:49 +02:00
Carlos Antonio da Silva
5a8f25f003 Refactor tests that switch RAILS_ENV and RACK_ENV
This cleanup aims to fix a build failure:
https://travis-ci.org/rails/rails/jobs/3515951/#L482

Since travis always have both ENV vars set to "test", a test is failing
where it's expected to output the default env "development", but "test"
is the result due to RACK_ENV being set when we expect it to not be.

By cleaning this duplication we ensure that changing any of these env
variables will pick the right expected value.
2012-12-06 10:47:14 -02:00
kennyj
a7695579a5 Add ENV['RACK_ENV'] support to rake runner/console/server. 2012-12-06 02:05:33 +09:00
Carlos Antonio da Silva
53aefdec91 Fix rails db command with sqlite3 database
When using sqlite3 it was attempting to find the database file based on
Rails.root, the problem is that Rails.root is not always present because
we try to first manually load "config/database.yml" instead of loading
the entire app, to make "rails db" faster.

This means that when we're in the root path of the app, calling "rails db"
won't allow us to use Rails.root, making the command fail for sqlite3
with the error:

    ./rails/commands/dbconsole.rb:62:in `start':
      undefined method `root' for Rails:Module (NoMethodError)

The fix is to simply not pass any dir string to File.expand_path, which
will make it use the current directory of the process as base, or the
root path of the app, which is what we want.

When we are in any other subdirectory, calling "rails db" should work
just fine, because "config/database.yml" won't be found, thus "rails db"
will fallback to loading the app, making Rails.root available.

Closes #8257.
2012-11-18 23:52:39 -02:00
Arun Agrawal
c33c991eab Removing warning : assigned but unused variable 2012-11-10 17:34:39 +05:30
Robin Dupret
5ad7f8ab41 Use Ruby 1.9 Hash syntax in railties 2012-10-14 18:26:58 +02:00
Arun Agrawal
3121ac06a9 warning fixed: ambiguous first argument; put parentheses or even spaces 2012-10-10 10:40:14 +05:30
Rafael Mendonça França
9a30d82d45 Set RACK_ENV to nil in the dbconsole test
This will fix the travis-ci build
2012-05-30 23:29:47 -03:00
Sam Oliver
dce0afd47f Remove support for rails server RAILS_ENV=env-name 2012-05-30 22:28:07 +01:00
Sam Oliver
cdd6d9b53a Fix various bugs with console arguments.
Allow hyphens in environment names again.
2012-05-30 22:23:04 +01:00
Arun Agrawal
05f88024de More assert_match warnings fixed. 2012-05-30 14:46:08 +05:30
Alexey Vakhov
1fed1f14fc Fix rails db -h and cosmetic fixes in usage banners
Ruby tries to use '-h' as short version of '--header' by default
https://github.com/ruby/ruby/blob/trunk/lib/optparse.rb#L1372-1381.
To force `rails db -h` prints an usage message we should add the `-h`
options explicitly.
2012-05-22 08:59:30 +04:00
Alexey Vakhov
a060c41ef7 Use relative path to sqlite3 db in rails db command
Rails uses sqlit3 db file with a path relative to the rails root. It
allows to execute server not from rails root only. For example you
can fire `./spec/dummy/script/rails s` to start dummy application
server if you develop some engine gem.

Now the `rails db` command uses relative paths also and you can explore
your dummy db via `./spec/dummy/script/rails db` command.
2012-05-22 08:59:25 +04:00
Piotr Sarnacki
d98bbdee14 Fix build 2012-05-06 21:38:34 -07:00
Dmitry Vorotilin
346bb01849 More faster rails dbconsole 2012-05-06 22:53:53 +04:00
Alexey Vakhov
5d685f9db7 Add Rails::DBConsole tests 2012-05-02 08:48:06 +04:00
schneems
7529283732 match rails console environment support, to server
rails server takes `-e` as an argument to specify RAILS_ENV, rails console currently does not have the same interface. This commit fixes this disparity so developers can manually specify `RAILS_ENV` or can pass in an environment with a `-e`.
2012-03-22 13:13:12 -04:00
schneems
0a555dd421 fix rails server support of RAILS_ENV variable
When launching rails server from the command line with a rails environment specified such as `rails server RAILS_ENV=production` an error would occur since rails will try to use `RAILS_ENV=production` as it's server. 

When launching rails with a specified server such as thin `rails server thin RAILS_ENV=production` no error will be thrown, but rails will not start up in the specified environment.

This fixes both of those cases
2012-03-20 20:58:50 -04:00
Piotr Sarnacki
c84e4b5d4b Fix tests, Rails.env may be different on CI 2012-02-16 21:26:01 +01:00
Piotr Sarnacki
dd655d88d6 Refactor Rails::Console to make it easier to test and add tests for it 2012-02-16 20:41:35 +01:00