Re-add and apply MDL rule MD040

We were following it about half of the time and we even added it to our
former `.mdlrc` file. However, for some reason, MDL doesn't detect this
rule when specified in the `.mdlrc` file, so we didn't notice we weren't
following it in many cases.

Now that we're using a style file to configure MDL, we can enable this
rule again and apply it, since now MDL correctly includes it in its
report.
This commit is contained in:
Javi Martín
2024-06-18 05:28:05 +02:00
parent cf23de2f8b
commit 819485eb80
33 changed files with 232 additions and 229 deletions

View File

@@ -8,7 +8,7 @@ Tests that fail randomly are called "flakies", this one seems to be one:
**Failure:**
```
```text
FILL_WITH_FAILURE_REPORT
```

View File

@@ -2,7 +2,6 @@ all
exclude_rule "MD013"
exclude_rule "MD024"
exclude_rule "MD029"
exclude_rule "MD040"
exclude_rule "MD041"
exclude_rule "MD046"

View File

@@ -45,13 +45,13 @@ bin/rake db:dev_seed
Para ejecutar la aplicación en local:
```
```bash
bin/rails s
```
Para ejecutar los tests:
```
```bash
bin/rspec
```

View File

@@ -38,7 +38,7 @@ The information to be filled in is divided into three sections:
To help you understand how to fill in each of the fields, we will rely on a supposed WebService that receives a method called `:get_habita_datos` with the following structure:
```
```ruby
{
request: {
codigo_institucion: 12, # Static Value
@@ -98,7 +98,7 @@ The information to be filled in is divided into three sections:
As in the previous section we will define an example answer, to help you understand how to fill in each of the fields in this section.
```
```ruby
{
get_habita_datos_response: {
get_habita_datos_return: {

View File

@@ -8,7 +8,7 @@ We should add in the model the attributes that are going to be translated. To do
We also need to add the option `globalize_accessors` to include all the locales we want to support. This gem generates all the methods needed by the application (`title_en`, `title_es`, etc.). If you want to include **all** the translated fields in **all** the defined languages in your application, just call `globalize_accessors` without any option (as the [documentation](https://github.com/globalize/globalize-accessors#example) says).
```
```ruby
# Supposing a model Post with title and text attributes
class Post < ActiveRecord::Base
@@ -21,7 +21,7 @@ end
We must create a migration to generate the table where the translations are going to be stored. The table must have a column for each attribute we want to translate. To migrate the stored data in the original table, add the option `:migrate_data => true` in the migration.
```
```ruby
class AddTranslatePost < ActiveRecord::Migration
def self.up
Post.create_translation_table!({
@@ -42,7 +42,7 @@ end
Add the `Translatable` module in the controller that will handle the translations.
```
```ruby
class PostController < Admin::BaseController
include Translatable
...
@@ -50,7 +50,7 @@ class PostController < Admin::BaseController
Make sure that the controller has the functions `resource_model` and `resource`, which return the name of the model and the object we want to save the translations for, respectively.
```
```ruby
...
def resource_model
Post
@@ -66,7 +66,7 @@ Make sure that the controller has the functions `resource_model` and `resource`,
Add as permitted params those dedicated to translations. To do that, the module `Translatable` owns a function called `translation_params(params)`, which will receive the object param and will return those keys with a value. It takes into account the languages defined for that model.
```
```ruby
# Following the example, we pass the params[:post] because is the one that has the information.
attributes = [:title, :description]
@@ -85,7 +85,7 @@ Remember that, to avoid errors when using locales like `pt-BR`, `es-ES`, etc. (t
Add the hidden parameters to the form to delete translations:
```
```erb
<%= hidden_field_tag "delete_translations[#{locale}]", 0 %>
```
@@ -95,7 +95,7 @@ We must add the link "Remove translation" to delete translations, which should h
- an attribute `data-locale` with the value of `neutral_locale(locale)`.
- the class `delete-language`.
```
```erb
<%= link_to t("admin.milestones.form.remove_language"), "#",
id: "delete-#{neutral_locale(locale)}",
class: 'delete-language',
@@ -108,7 +108,7 @@ The CSS styles and the rest of the classes will depend on the designed UI for th
So that they will be generated when the DB is restored. For example, to create a post whose description is translated.
```
```ruby
section "Creating post with translations" do
post = Post.new(title: title)
I18n.available_locales.map do |locale|

View File

@@ -36,7 +36,7 @@ One of the characteristics that differentiates a REST API from a GraphQL one is
GraphQL queries are written following a standard which resembles to JSON, for example:
```
```graphql
{
proposal(id: 1) {
id,
@@ -140,7 +140,7 @@ The models are the following:
### Request a single record from a collection
```
```graphql
{
proposal(id: 2) {
id,
@@ -166,7 +166,7 @@ Response:
### Request a complete collection
```
```graphql
{
proposals {
edges {
@@ -205,7 +205,7 @@ Response:
The maximum (and default) number of records that each page contains is set to 25. For navigating through the different pages it's necessary to request also information relative to the `endCursor`:
```
```graphql
{
proposals(first: 25) {
pageInfo {
@@ -242,7 +242,7 @@ The response:
To retrieve the next page, you have to pass as a parameter the cursor received in the previous request, and so on:
```
```graphql
{
proposals(first: 25, after: "NQ==") {
pageInfo {
@@ -262,7 +262,7 @@ To retrieve the next page, you have to pass as a parameter the cursor received i
This query requests information about several models in a single request: `Proposal`, `User`, `Geozone` and `Comment`:
```
```graphql
{
proposal(id: 15262) {
id,
@@ -298,7 +298,7 @@ There are three main mechanisms to prevent such abuses:
The maximum depth of queries is currently set at 8. Deeper queries (such as the following) will be rejected:
```
```graphql
{
user(id: 1) {
public_proposals {
@@ -339,7 +339,7 @@ The response will look something like this:
The main risk factor is when multiple collections of resources are requested in the same query. The maximum number of collections that can appear in the same query is limited to 2. The following query requests information from the `users`, `debates` and `proposals` collections, so it will be rejected:
```
```graphql
{
users {
edges {
@@ -384,7 +384,7 @@ The response will look something like this:
However, it is possible to request information belonging to more than two models in a single query, as long as you do not try to access the entire collection. For example, the following query that accesses the `User`, `Proposal` and `Geozone` models is valid:
```
```graphql
{
user(id: 468501) {
id

View File

@@ -14,7 +14,7 @@ If you're upgrading a Consul Democracy installation to version 2.0.0 from versio
First, after deploying version 2.0.0 to your production server, execute the release tasks:
```
```bash
RAILS_ENV=production bin/rails consul:execute_release_tasks
```
@@ -26,13 +26,13 @@ If that's the case, restart the application. If not, make sure the `config/datab
Next, open a database console with a user having permission to create and manage database extensions:
```
```bash
sudo -u postgres psql -d consul_production
```
If you didn't use the [installer](https://github.com/consuldemocracy/installer/) to install Consul Democracy, you might need to execute a couple of queries to make sure the Rails database user has permission to create schemas and the shared extensions schema has the right permissions:
```
```sql
CREATE SCHEMA shared_extensions AUTHORIZATION <replace_with_rails_database_username>;
GRANT CREATE ON DATABASE consul_production TO <replace_with_rails_database_username>;
GRANT usage ON SCHEMA shared_extensions TO public;
@@ -40,7 +40,7 @@ GRANT usage ON SCHEMA shared_extensions TO public;
Whether or not you installed Consul Democracy with the installer, run:
```
```sql
ALTER EXTENSION pg_trgm SET SCHEMA shared_extensions;
ALTER EXTENSION unaccent SET SCHEMA shared_extensions;
```
@@ -88,13 +88,13 @@ If you've installed Consul Democracy using the installer and are using Certbot t
One option would be adding each certificate manually every time you create a tenant. For example, in orer to add a tenant using the `mars` subdomain in the `solarsystemexample.org` domain, run:
```
```bash
sudo certbot certonly --nginx --noninteractive --agree-tos --expand -d solarsystemexample.org,mars.solarsystemexample.org
```
If you're going to add many subdomains at different times, this task can be tedious. Another option is enabling any subdomain. In order to achieve this goal, you need access to your DNS configuration in order to follow the instructions you'll get by either using one of the [Certbot DNS plugins](https://eff-certbot.readthedocs.io/en/stable/using.html#dns-plugins) or the [manual generation of the certificate](https://eff-certbot.readthedocs.io/en/stable/using.html#manual) with the following command:
```
```bash
sudo certbot certonly --manual --agree-tos --expand -d solarsystemexample.org,*.solarsystemexample.org
```
@@ -110,7 +110,7 @@ In order to reduce the chance your application sends emails which are erronously
If you'd like to use a different mail configuration for the new tenant, like one for a hypothetical `jupiter` subdomain, edit the `config/secrets.yml` file this way:
```
```yaml
production:
# (...) Other secrets
multitenancy: true
@@ -138,7 +138,7 @@ The first option is changing your existing application using the Twitter/Google/
The other option is creating a new Twitter/Google/Facebook/Wordpress application and configuring it so it can be used from the new tenant. In this case, you'll have to add the configuration of this application to the `config/secrets.yml` file. For example, if you've added a tenant using the `saturn` subdomain, edit the file this way, filling in the keys and secrets of the services you're using:
```
```yaml
production:
# (...) Other secrets
multitenancy: true
@@ -172,7 +172,7 @@ When the multitenancy feature is enabled, Consul Democracy adds a class to the `
This way, it'll be possible to overwrite the default styles for just this tenant by creating a new stylesheet in the `app/assets/stylesheets/custom/` folder:
```
```css
.tenant-uranus {
// Styles that will only be applied to the Uranus tenant
}
@@ -180,7 +180,7 @@ This way, it'll be possible to overwrite the default styles for just this tenant
To easily change the default colors on a specific tenant, you can use CSS variables; their usage is documented in the [app/assets/stylesheets/custom/tenants.scss](https://github.com/consuldemocracy/consuldemocracy/blob/master/app/assets/stylesheets/custom/tenants.scss) file. For example, to make the brand colors green on the tenant with the `uranus` subdomain, write:
```
```css
.tenant-uranus {
--brand: #350;
--brand-secondary: #173a00;

View File

@@ -4,30 +4,30 @@
You could create a user called `deploy` or any other name. As as example, we are going to create a user named `jupiter`.
```
adduser jupiter
```
```bash
adduser jupiter
```
I'm using jupiter as the user name, you should change that for whatever makes sense to you. Input a password when prompted, and just leave empty the rest of the options.
Let's create a `wheel` group and add the user `jupiter` to this group.
```
sudo groupadd wheel
sudo usermod -a -G wheel jupiter
```
```bash
sudo groupadd wheel
sudo usermod -a -G wheel jupiter
```
Now let's give sudo privileges to the `wheel` group and allow it to not use a password, this is important so that the installer doesn't get stalled waiting for a password.
First we open the sudoers file:
```
```bash
sudo visudo -f /etc/sudoers
```
And we add this line at the end:
```
```text
%wheel ALL=(ALL) NOPASSWD: ALL
```
@@ -35,7 +35,7 @@ Now we need to give the keys of the server to the new user. Dont close the se
Let's create the necessary directory in the server to upload the public key:
```
```bash
su jupiter
cd ~
mkdir .ssh
@@ -47,7 +47,7 @@ Make sure you have [generated a public key](generating_ssh_key.md) in your local
Open another local terminal window (not in the server) and type:
```
```bash
cat ~/.ssh/id_rsa.pub
```
@@ -55,26 +55,26 @@ Copy the content of your public key to the file authorized_keys that should stil
Test that your user can log in by typing:
```
ssh jupiter@your-copied-ip-address
```
```bash
ssh jupiter@your-copied-ip-address
```
You should see the server welcome page and a prompt like this:
```
jupiter@consuldemocracyserver:~$
```
```bash
jupiter@consuldemocracyserver:~$
```
Note the username at the prompt is not "root", but your username. So everything is fine and we can now block the root account from outside access and also stop allowing password access so only people with SSH keys can log in.
Type the following command to edit the SSH config file of the server:
```
sudo nano /etc/ssh/sshd_config
```
```bash
sudo nano /etc/ssh/sshd_config
```
Look for the "PasswordAuthentication yes" line and change it to "PasswordAuthentication no". Type Control-K to close the nano editor and type:
```
sudo service ssh restart
```
```bash
sudo service ssh restart
```

View File

@@ -4,7 +4,7 @@
Note that 'sudo' is not installed by default in Debian. It's possible to install and configure it, you can find information [here](https://wiki.debian.org/sudo). But we don't recommend it cause you may have other problems. We recommend running the following commands as a superuser, so make sure the very first command you run is:
```
```bash
su
```
@@ -25,7 +25,7 @@ apt-get update
Git is officially maintained in Debian:
```
```bash
apt-get install git
```
@@ -33,7 +33,7 @@ apt-get install git
Curl is officially maintained in Debian:
```
```bash
apt-get install curl
```
@@ -45,7 +45,7 @@ One possible tool is rvm:
### As a local user
```
```bash
command curl -sSL https://rvm.io/mpapis.asc | gpg --import -
command curl -sSL https://rvm.io/pkuczynski.asc | gpg --import -
curl -L https://get.rvm.io | bash -s stable
@@ -53,13 +53,13 @@ curl -L https://get.rvm.io | bash -s stable
then add rvm script source to user's bash (~/.bashrc) (this step is only necessary if you can't execute the rvm command)
```
```bash
[[ -s /usr/local/rvm/scripts/rvm ]] && source /usr/local/rvm/scripts/rvm
```
and finally, reload .bashrc to be able to run RVM
```
```bash
source ~/.bashrc
```
@@ -71,7 +71,7 @@ To install it, you can use [n](https://github.com/tj/n)
Run the following command on your terminal:
```
```bash
curl -L https://git.io/n-install | bash -s -- -y lts
```
@@ -79,13 +79,13 @@ And it will install the latest LTS (Long Term Support) Node version on your `$HO
Reload .bashrc to be able to run node
```
```bash
source /root/.bashrc
```
Check it's correctly installed by running:
```
```bash
node -v
```
@@ -97,27 +97,27 @@ So you have to add a repository, the official postgresql works fine.
Add the repository to apt, for example creating file */etc/apt/sources.list.d/pgdg.list* with:
```
```text
deb http://security.debian.org/debian-security jessie/updates main
```
afterwards you'll have to download the key, and install it, by:
```
```bash
wget https://www.postgresql.org/media/keys/ACCC4CF8.asc
apt-key add ACCC4CF8.asc
```
and install postgresql
```
```bash
apt-get update
apt-get install postgresql-9.4 postgresql-server-dev-9.4 postgresql-contrib-9.4
```
You also need to configure a user for your database. As an example, we'll choose the username "consul":
```
```bash
su - postgres
createuser consul --createdb --superuser --pwprompt

View File

@@ -113,7 +113,7 @@ Add the SendGrid add-on in Heroku. It will create a SendGrid account for you wit
Add this to `config/secrets.yml`, under the `production:` section:
```
```yaml
mailer_delivery_method: :smtp
smtp_settings:
:address: "smtp.sendgrid.net"

View File

@@ -26,15 +26,15 @@ In the "Add you SSH keys" section click "New SSH Key" button.
In the pop up window that appears you need to copy and paste the public key that we [generated in the previous step](generating_ssh_key.md). To see the content of this key in the terminal window type:
```
cat ~/.ssh/id_rsa.pub
```
```bash
cat ~/.ssh/id_rsa.pub
```
You should see a text like this:
```
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDy/BXU0OsK8KLLXpd7tVnqDU+d4ZS2RHQmH+hv0BFFdP6PmUbKdBDigRqG6W3QBexB2DpVcb/bmHlfhzDlIHJn/oki+SmUYLSWWTWuSeF/1N7kWf9Ebisk6hiBkh5+i0oIJYvAUsNm9wCayQ+i3U3NjuB25HbgtyjR3jDPIhmg1xv0KZ8yeVcU+WJth0pIvwq+t4vlZbwhm/t2ah8O7hWnbaGV/MZUcj0/wFuiad98yk2MLGciV6XIIq+MMIEWjrrt933wAgzEB8vgn9acrDloJNvqx25uNMpDbmoNXJ8+/P3UDkp465jmejVd/6bRaObXplu2zTv9wDO48ZpsaACP your_username@your_computer_name
```
```text
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDy/BXU0OsK8KLLXpd7tVnqDU+d4ZS2RHQmH+hv0BFFdP6PmUbKdBDigRqG6W3QBexB2DpVcb/bmHlfhzDlIHJn/oki+SmUYLSWWTWuSeF/1N7kWf9Ebisk6hiBkh5+i0oIJYvAUsNm9wCayQ+i3U3NjuB25HbgtyjR3jDPIhmg1xv0KZ8yeVcU+WJth0pIvwq+t4vlZbwhm/t2ah8O7hWnbaGV/MZUcj0/wFuiad98yk2MLGciV6XIIq+MMIEWjrrt933wAgzEB8vgn9acrDloJNvqx25uNMpDbmoNXJ8+/P3UDkp465jmejVd/6bRaObXplu2zTv9wDO48ZpsaACP your_username@your_computer_name
```
Select and copy all the text and paste it in the pop-up window like this:

View File

@@ -91,7 +91,7 @@ POSTGRES_PASSWORD=password docker-compose up -d database
You can now initialize your development DB and populate it with:
```
```bash
POSTGRES_PASSWORD=password docker-compose run app rake db:create db:migrate
POSTGRES_PASSWORD=password docker-compose run app rake db:dev_seed
```

View File

@@ -4,15 +4,15 @@ These instructions will help you generate a public key with which you can connec
In the terminal window, type:
```
ssh-keygen
```
```bash
ssh-keygen
```
When prompted for the file in which to save the key just press ENTER to leave the default. When prompted for a passphrase, just press ENTER again to leave this empty. At the end you should see a message like this:
```
Your identification has been saved in /your_home/.ssh/id_rsa.
Your public key has been saved in /your_home/.ssh/id_rsa.pub.
```
```text
Your identification has been saved in /your_home/.ssh/id_rsa.
Your public key has been saved in /your_home/.ssh/id_rsa.pub.
```
Take note of the **id_rsa.pub** file location, because youll need the content of this file later.

View File

@@ -28,7 +28,7 @@ To install it, you can use [n](https://github.com/tj/n)
Run the following command on your terminal:
```
```bash
curl -L https://git.io/n-install | bash -s -- -y lts
```
@@ -36,19 +36,19 @@ And it will install the latest LTS (Long Term Support) Node version on your `$HO
## PostgreSQL (>=9.4)
```
```bash
brew install postgres
```
Once installed, we need to *initialize* it:
```
```bash
initdb /usr/local/var/postgres
```
Now we're going to configure some things related to the *default user*. First we start postgres server with:
```
```bash
postgres -D /usr/local/var/postgres
```
@@ -56,7 +56,7 @@ At this point we're supposed to have postgres correctly installed and a default
If we run `psql` we'll login into the postgres console with the default user. Probably it will fail since its required that a default database exists for that user. We can create it by typing:
```
```bash
createdb 'your_username'
```
@@ -64,13 +64,13 @@ If we run `psql` again we should now get access to postgres console. With `\du`
In case you want to set a password for your user you can make it through postgres console by:
```
```sql
ALTER USER your_username WITH PASSWORD 'your_password';
```
Now we'll create the *consul* user, the one the application is using. Run in postgres console:
```
```sql
CREATE ROLE consul WITH PASSWORD '000';
ALTER ROLE consul WITH SUPERUSER;
ALTER ROLE consul WITH login;
@@ -78,25 +78,25 @@ ALTER ROLE consul WITH login;
If at any point during PostgreSQL installation you feel you have messed things up, you can uninstall it and start again by running:
```
```bash
brew uninstall postgres
```
You'll have to delete also this directory (otherwise the new installation will generate conflicts, source: [gist.github.com/lxneng/741932](https://gist.github.com/lxneng/741932)):
```
```bash
rm -rf /usr/local/var/postgres
```
## ChromeDriver
```
```bash
brew install chromedriver
```
## Imagemagick
```
```bash
brew install imagemagick
```

View File

@@ -10,7 +10,7 @@ The created directory structure herein is to be used with [capistrano](https://c
First, create the main folder, clone the repo to a repo directory, and create the needed folders:
```
```bash
mkdir consul
cd consul
git clone --mirror https://github.com/consuldemocracy/consuldemocracy.git repo
@@ -23,7 +23,7 @@ mkdir -p shared/public/assets shared/public/system shared/public/ckeditor_assets
Extract from the repo the first release to the respective directory, and create the symbolic link of the current release (replace `<latest_consuldemocracy_stable_version>` with the latest version number, like 1.3.1 or 1.4.1):
```
```bash
cd repo
git archive <latest_consuldemocracy_stable_version> | tar -x -f - -C ../releases/first
cd ..
@@ -34,7 +34,7 @@ ln -s releases/first current
Install the gems Consul Democracy depends on:
```
```bash
cd releases/first
bundle install --path ../../shared/bundle --without development test
cd ../..
@@ -44,7 +44,7 @@ cd ../..
Generate the `database.yml` and `secrets.yml` files:
```
```bash
cp current/config/secrets.yml.example shared/config/secrets.yml
cp current/config/database.yml.example shared/config/database.yml
cd releases/first/config
@@ -57,7 +57,7 @@ Edit the `shared/config/database.yml` file, filling in `username` and `password`
We now need to generate a secret key:
```
```bash
cd current
bin/rake secret RAILS_ENV=production
cd ..
@@ -65,7 +65,7 @@ cd ..
Copy that generated key, and edit the `shared/config/secrets.yml` file; under the section `production`, change the following data:
```
```yaml
secret_key_base: enter_the_secret_key_you_have_just_generated
server_name: enter_your_domain
```
@@ -76,7 +76,7 @@ If you aren't using a SSL certificate, replace the line saying `force_ssl: true`
Create a database, load the seeds and compile the assets:
```
```bash
cd current
bin/rake db:migrate RAILS_ENV=production
bin/rake db:seed RAILS_ENV=production
@@ -87,7 +87,7 @@ Create a database, load the seeds and compile the assets:
And, finally, start the Rails server:
```
```bash
bin/rails s -e production
```

View File

@@ -61,13 +61,13 @@ sudo -u postgres createuser consul --createdb --superuser --pwprompt
To make sure the UTF-8 enconding is used, create a file:
```
```bash
sudo nano /etc/profile.d/lang.sh
```
Add the following:
```
```bash
export LANGUAGE="en_US.UTF-8"
export LANG="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
@@ -75,10 +75,12 @@ export LC_ALL="en_US.UTF-8"
Reconfigure Postgres to use the UTF-8 encoding:
`````
```bash
sudo su - postgres
psql
```
```sql
update pg_database set datistemplate=false where datname='template1';
drop database Template1;
create database template1 with owner=postgres encoding='UTF-8'
@@ -87,7 +89,7 @@ update pg_database set datistemplate=true where datname='template1';
\q
exit
`````
```
## Imagemagick

View File

@@ -12,13 +12,13 @@ This tutorial explains how to configure Paperclip to use [AWS S3](https://aws.am
First, add the following line in your *Gemfile_custom*
```
```ruby
gem 'aws-sdk-s3', '~> 1'
```
Make sure to have a recent version of paperclip (Consul Democracy is currently using 5.2.1, which doesn't recognize *aws-sdk-s3*). In your Gemfile, the line should be:
```
```ruby
gem 'paperclip', '~> 6.1.0'
```
@@ -41,7 +41,7 @@ Once you have these pieces of information, you can save them as environment vari
Add the following block in your *secrets.yml* file:
```
```yaml
aws: &aws
aws_s3_region: <%= ENV["AWS_S3_REGION"] %>
aws_access_key_id: <%= ENV["AWS_ACCESS_KEY_ID"] %>
@@ -52,7 +52,7 @@ aws: &aws
and `<<: *aws` under the environments which you want to use S3 with, for example:
```
```yaml
production:
[...]
<<: *aws
@@ -62,13 +62,13 @@ production:
First, activate Paperclip's URI adapter by creating the file *config/initializers/paperclip.rb* with the following content:
```
```ruby
Paperclip::UriAdapter.register
```
Finally, add the following lines in the environment file of the instance which you want to use S3 with. In production, you should for example edit *config/environments/production.rb*.
```
```ruby
# Paperclip settings to store images and documents on S3
config.paperclip_defaults = {
storage: :s3,

View File

@@ -12,25 +12,25 @@ To access the application through the browser at `localhost:3000` we must forwar
Open the Vagrant configuration file:
```
```bash
nano Vagranfile
```
Find this line:
```
```ruby
# config.vm.network "forwarded_port", guest: 80, host: 8080
```
And change it for this configuration:
```
```ruby
config.vm.network "forwarded_port", guest: 3000, host: 3000
```
Reload your virtual machine:
```
```bash
vagrant reload
```
@@ -38,7 +38,7 @@ vagrant reload
In your virtual machine, run the application server, binding to your local ip address:
```
```bash
bin/rails s -b 0.0.0.0
```

View File

@@ -23,13 +23,13 @@ bin/rake db:dev_seed
Para ejecutar la aplicación en local:
```
```bash
bin/rails s
```
Para ejecutar los tests:
```
```bash
bin/rspec
```

View File

@@ -38,7 +38,7 @@ La información a rellenar esta dividida en tres apartados:
Para ayudar a entender como rellenar cada uno de los campos, nos basaremos en un supuesto WebService que recibe un método llamado `:get_habita_datos` con la siguiente estructura:
```
```ruby
{
request: {
codigo_institucion: 12, #Valor estático
@@ -99,7 +99,7 @@ La información a rellenar esta dividida en tres apartados:
Al igual que en el apartado anterior definiremos un ejemplo de respuesta, para ayudar a entender como rellenar cada uno de los campos de esta sección.
```
```ruby
{
get_habita_datos_response: {
get_habita_datos_return: {

View File

@@ -8,7 +8,7 @@ Hay que definir los atributos que se quieran traducir en el modelo. Para ello, h
También deberemos añadir la opción `globalize_accessors` con todos aquellos locales a los que queramos tener acceso. Esta gema generará los métodos `title_en`, `title_es`, etc., y que se usan en la aplicación. Si lo que quieres es incluir **todos** los campos traducidos en **todos** los idiomas definidos en tu aplicación, puedes llamar a `globalize_accessors` sin ninguna opción (tal y como se explica en la [documentación](https://github.com/globalize/globalize-accessors#example)).
```
```ruby
# Suponiendo un modelo Post con attributos title y text
class Post < ActiveRecord::Base
@@ -21,7 +21,7 @@ end
Hay que crear una migración para generar la tabla donde se almacenarán todas las traducciones de ese modelo. La tabla deberá tener una columna por cada atributo que queramos traducir. Para migrar los datos ya almacenados (en la tabla original), hay que añadir la opción `:migrate_data => true` en la propia migración:
```
```ruby
class AddTranslatePost < ActiveRecord::Migration
def self.up
Post.create_translation_table!({
@@ -42,7 +42,7 @@ end
Añadir el módulo `Translatable` en el controlador que vaya a gestionar las traducciones.
```
```ruby
class Post < Admin::BaseController
include Translatable
...
@@ -50,7 +50,7 @@ class Post < Admin::BaseController
Hay que asegurarse de que este controlador tiene las funciones `resource_model` y `resource`, que devuelven el nombre del modelo y el objeto para el que se van a gestionar las traducciones, respectivamente.
```
```ruby
...
def resource_model
Post
@@ -66,7 +66,7 @@ Hay que asegurarse de que este controlador tiene las funciones `resource_model`
Añadir como parámetros permitidos aquellos que estén dedicados a las traducciones. Para eso, el módulo `Translatable` posee una función llamada `translation_params(params)`, a la que se le pasan el parámetro del objeto. A partir de esos parámetros, y teniendo en cuenta los idiomas definidos para ese modelo, la función devuelve aquellos parámetros que contengan un valor.
```
```ruby
# Siguiendo con el ejemplo, en este caso se le pasarían los parámetros params[:post], porque es el
# hash que contiene toda la información.
@@ -86,7 +86,7 @@ Recuerda que, para evitar errores al usar locales como `pt-BR`, `es-ES`, etc. (a
Al formulario que se use para editar las traducciones se le deberá añadir el parámetro oculto que las marca para que se borren:
```
```erb
<%= hidden_field_tag "delete_translations[#{locale}]", 0 %>
```
@@ -96,7 +96,7 @@ También habrá que añadir el link de "Eliminar idioma", que deberá tener:
- un atributo `data-locale` con el valor de `neutral_locale(locale)`.
- la clase `delete-language`.
```
```erb
<%= link_to t("admin.milestones.form.remove_language"), "#",
id: "delete-#{neutral_locale(locale)}",
class: 'delete-language',
@@ -109,7 +109,7 @@ Los estilos de CSS y el resto de clases que se le quieran añadir dependerán de
Para que se generen cuando se restablezca la base de datos. Por ejemplo, para crear un post cuya descripción está traducida:
```
```ruby
section "Creating post with translations" do
post = Post.new(title: title)
I18n.available_locales.map do |locale|

View File

@@ -36,7 +36,7 @@ Una de las caracteríticas que diferencian una API REST de una GraphQL es que co
Las consultas en GraphQL están escritas siguiendo un estándar que presenta ciertas similitudes con el formato JSON, por ejemplo:
```
```graphql
{
proposal(id: 1) {
id,
@@ -140,7 +140,7 @@ La lista de modelos es la siguiente:
<h3 id="recuperar-un-unico-elemento-de-una-coleccion">Recuperar un único elemento de una colección</h3>
```
```graphql
{
proposal(id: 2) {
id,
@@ -166,7 +166,7 @@ Respuesta:
<h3 id="recuperar-una-coleccion-completa">Recuperar una colección completa</h3>
```
```graphql
{
proposals {
edges {
@@ -205,7 +205,7 @@ Respuesta:
Actualmente el número máximo (y por defecto) de elementos que se devuelven en cada página está establecido a 25. Para poder navegar por las distintas páginas es necesario solicitar además información relativa al `endCursor`:
```
```graphql
{
proposals(first: 25) {
pageInfo {
@@ -242,7 +242,7 @@ La respuesta:
Para recuperar la siguiente página, hay que pasar como parámetro el cursor recibido en la petición anterior, y así sucesivamente:
```
```graphql
{
proposals(first: 25, after: "NQ==") {
pageInfo {
@@ -262,7 +262,7 @@ Para recuperar la siguiente página, hay que pasar como parámetro el cursor rec
Esta consulta solicita información relativa a varios modelos distintos en una única petición: `Proposal`, `User`, `Geozone` y `Comment`:
```
```graphql
{
proposal(id: 15262) {
id,
@@ -298,7 +298,7 @@ Existen tres mecanismos principales para evitar este tipo de abusos:
La profundidad máxima de las consultas está actualmente establecida en 8. Consultas más profundas (como la siguiente), serán rechazadas:
```
```graphql
{
user(id: 1) {
public_proposals {
@@ -339,7 +339,7 @@ La respuesta obtenida tendrá el siguiente aspecto:
El principal factor de riesgo se da cuando se solicitan varias colecciones de recursos en una misma consulta. El máximo número de colecciones que pueden aparecer en una misma consulta está limitado a 2. La siguiente consulta solicita información de las colecciónes `users`, `debates` y `proposals`, así que será rechazada:
```
```graphql
{
users {
edges {
@@ -384,7 +384,7 @@ La respuesta obtenida tendrá el siguiente aspecto:
No obstante sí que es posible solicitar información perteneciente a más de dos modelos en una única consulta, siempre y cuando no se intente acceder a la colección completa. Por ejemplo, la siguiente consulta que accede a los modelos `User`, `Proposal` y `Geozone` es válida:
```
```graphql
{
user(id: 468501) {
id

View File

@@ -14,7 +14,7 @@ Si has actualizado una instalación de Consul Democracy a la versión 2.0.0 desd
Así, en primer lugar, tras subir la versión 2.0.0 al servidor de producción, tendrás que ejecutar las tareas de actualización de versión:
```
```bash
RAILS_ENV=production bin/rails consul:execute_release_tasks
```
@@ -26,13 +26,13 @@ Si es así, reincia la aplicación. Si no has recibido este aviso, comprueba que
Una vez hecho esto, deberás abrir una consola de base de datos utilizando un usuario que tenga permisos para crear y modificar extensiones de base de datos:
```
```bash
sudo -u postgres psql -d consul_production
```
Si no usaste el [instalador](https://github.com/consuldemocracy/installer/) para instalar Consul Democracy, es posible que tengas que ejecutar las siguientes consultas de base de datos para garantizar los permisos del usuario de Rails para crear esquemas así como el acceso al esquema de extensiones compartidas:
```
```sql
CREATE SCHEMA shared_extensions AUTHORIZATION <reemplazar_con_usuario_de_rails_de_base_de_datos>;
GRANT CREATE ON DATABASE consul_production TO <reemplazar_con_usuario_de_rails_de_base_de_datos>;
GRANT usage ON SCHEMA shared_extensions TO public;
@@ -40,7 +40,7 @@ GRANT usage ON SCHEMA shared_extensions TO public;
Tanto si usaste el instalador como si no, ejecuta:
```
```sql
ALTER EXTENSION pg_trgm SET SCHEMA shared_extensions;
ALTER EXTENSION unaccent SET SCHEMA shared_extensions;
```
@@ -88,13 +88,13 @@ Si has instalado Consul Democracy usando el instalador y estás usando Certbot p
Una opción es añadir manualmente cada certificado cada vez que creas una entidad. Por ejemplo, para añadir la entidad con subdominio `marte` al dominio `ejemplodesistemasolar.org`, ejecuta:
```
```bash
sudo certbot certonly --nginx --noninteractive --agree-tos --expand -d ejemplodesistemasolar.org,marte.ejemplodesistemasolar.org
```
Si vas a añadir muchos subdominios en distintos momentos, esta tarea puede resultar tediosa. Una alternativa es habilitar cualquier subdominio. Para conseguir esto, deberás tener acceso al panel de administración de tu dominio (DNS) para poder seguir las instrucciones al utilizar bien alguno de los [plugins DNS de Certbot](https://eff-certbot.readthedocs.io/en/stable/using.html#dns-plugins) o la [generación manual del certificado](https://eff-certbot.readthedocs.io/en/stable/using.html#manual) con la siguiente orden:
```
```bash
sudo certbot certonly --manual --agree-tos --expand -d ejemplodesistemasolar.org,*.ejemplodesistemasolar.org
```
@@ -110,7 +110,7 @@ Para disminuir la probabilidad de que los correos enviados por la aplicación se
Si quieres utilizar una configuración de envío de correo electrónico diferente para una entidad, como podría ser una que utilice `jupiter` como subdominio, edita el fichero `config/secrets.yml` de la siguiente manera:
```
```yaml
production:
# (...) Otros secretos
multitenancy: true
@@ -138,7 +138,7 @@ Como primera opción, en el panel de configuración de Twitter/Google/Facebook/W
Y como segunda opción, puedes crear una nueva aplicación de Twitter/Google/Facebook/Wordpress y configurarla para su uso desde el dominio de la nueva entidad. En este caso, deberás añadir la configuración de esta aplicación al fichero `config/secrets.yml`. Por ejemplo, si administrases una entidad con el subdominio `saturno`, edita el fichero de esta manera, rellenando la información de aquellos servicios que estés utilizando:
```
```yaml
production:
# (...) Otros secretos
multitenancy: true
@@ -172,7 +172,7 @@ Cuando la funcionalidad de multientidad está activada, Consul Democracy añade
Así, es posible sobrescribir los estilos para una entidad específica añadiendo a alguna hoja de estilos en la carpeta `app/assets/stylesheets/custom/`:
```
```css
.tenant-urano {
// Estilos que solamente se aplican a Urano
}
@@ -180,7 +180,7 @@ Así, es posible sobrescribir los estilos para una entidad específica añadiend
Para cambiar los colores en una determinada entidad de forma sencilla, puedes utilizar variables de CSS; su uso aparece documentado en el fichero [app/assets/stylesheets/custom/tenants.scss](https://github.com/consuldemocracy/consuldemocracy/blob/master/app/assets/stylesheets/custom/tenants.scss). Por ejemplo, para utilizar tonos de verde en los colores principales de la entidad con subdominio `urano`, puedes escribir:
```
```css
.tenant-urano {
--brand: #350;
--brand-secondary: #173a00;

View File

@@ -4,18 +4,18 @@
Puede crear un usuario llamado `deploy` o utilizar cualquier otro nombre. Como ejemplo, vamos a crear un usuario llamado `jupiter`.
```
adduser jupiter
```
```bash
adduser jupiter
```
Estoy usando jupiter como nombre de usuario, debería cambiar eso por lo que sea que tenga sentido para usted. Introduzca una contraseña cuando se le pida y deje vacías el resto de las opciones.
Creemos un grupo `wheel` y añadamos al usuario `jupiter` al grupo.
```
sudo groupadd wheel
sudo usermod -a -G wheel jupiter
```
```bash
sudo groupadd wheel
sudo usermod -a -G wheel jupiter
```
**Recuerde cambiar jupiter** por cualquier nombre de usuario que haya elegido en el paso anterior.
@@ -23,13 +23,13 @@ Ahora démosle al grupo `wheel` derechos de superadministración sin necesidad d
Primero debemos abrir el archivo `sudoers`:
```
```bash
sudo visudo -f /etc/sudoers
```
Y añadimos esta línea al final del archivo:
```
```text
%wheel ALL=(ALL) NOPASSWD: ALL
```
@@ -37,7 +37,7 @@ Ahora tenemos que dar las claves del servidor al nuevo usuario. No cierre la ven
Y escriba los siguientes comandos para crear el archivo necesario donde subir la clave pública:
```
```bash
su jupiter
cd ~
mkdir .ssh
@@ -49,7 +49,7 @@ Asegúrese que ha [generado una clave pública](generating_ssh_key.md) en su ter
Abra otra ventana de terminal local (no en el servidor) y escriba:
```
```bash
cat ~/.ssh/id_rsa.pub
```
@@ -57,26 +57,26 @@ Copie el contenido de ese comando al archivo `authorized_keys` que debería segu
Compruebe que su usuario puede iniciar sesión escribiendo:
```
ssh jupiter@your-copied-ip-address
```
```bash
ssh jupiter@your-copied-ip-address
```
Debería ver la página de bienvenida del servidor y un mensaje como este:
```
jupiter@consuldemocracyserver:~$
```
```bash
jupiter@consuldemocracyserver:~$
```
Note que el nombre de usuario en el prompt no es "root", sino su nombre de usuario. Así que todo está bien y ahora podemos bloquear la cuenta root del acceso externo y también dejar de permitir el acceso con contraseña para que sólo las personas con claves SSH puedan iniciar sesión.
Escriba el siguiente comando para editar el archivo de configuración SSH del servidor:
```
sudo nano /etc/ssh/sshd_config
```
```bash
sudo nano /etc/ssh/sshd_config
```
Busque la línea "PasswordAuthentication yes" y cámbiela por "PasswordAuthentication no". Escriba Control-K para cerrar el editor nano y escriba:
```
sudo service ssh restart
```
```bash
sudo service ssh restart
```

View File

@@ -4,7 +4,7 @@
El programa 'sudo' no viene instalado en Debian por defecto. Su instalación y configuración es posible, se puede encontrar información al respecto [aquí](https://wiki.debian.org/es/sudo). Pero no lo recomendamos porque puede causar otros problemas. Recomendamos que se ejecuten las siguientes instrucciones como un super usuario, así que asegúrate de que la primera instrucción que ejecutes sea:
```
```bash
su
```
@@ -25,7 +25,7 @@ apt-get update
Git es mantenido oficialmente en Debian:
```
```bash
apt-get install git
```
@@ -33,7 +33,7 @@ apt-get install git
Curl es mantenido oficialmente en Debian:
```
```bash
apt-get install curl
```
@@ -45,7 +45,7 @@ Una opción es utilizar rvm:
### Como usuario local
```
```bash
command curl -sSL https://rvm.io/mpapis.asc | gpg --import -
command curl -sSL https://rvm.io/pkuczynski.asc | gpg --import -
curl -L https://get.rvm.io | bash -s stable
@@ -53,13 +53,13 @@ curl -L https://get.rvm.io | bash -s stable
después añadimos el script rvm a nuestro bash (~/.bashrc) (este paso sólo es necesario si no puedes ejecutar el comando rvm)
```
```bash
[[ -s /usr/local/rvm/scripts/rvm ]] && source /usr/local/rvm/scripts/rvm
```
por úlitmo, volvemos a cargar el .bashrc para poder ejecutar RVM
```
```bash
source ~/.bashrc
```
@@ -71,7 +71,7 @@ Para instalar Node, puedes usar [n](https://github.com/tj/n)
Ejecuta el siguiente comando en tu terminal:
```
```bash
curl -L https://git.io/n-install | bash -s -- -y lts
```
@@ -79,13 +79,13 @@ Y este instalará automáticamente la versión LTS (_Long Term Support_, inglés
vuelve a cargar el .bashrc para poder ejecutar node
```
```bash
source /root/.bashrc
```
Comprueba que está correctamente instalado ejecutando:
```
```bash
node -v
```
@@ -95,27 +95,27 @@ La versión 9.4 de PostgreSQL no es oficial en Debian 9.
Así que debemos añadir el respositorio oficial de postgresql a apt, por ejemplo creando el fichero */etc/apt/sources.list.d/pgdg.list* con:
```
```text
deb http://security.debian.org/debian-security jessie/updates main
```
después deberás descargar la key e instalarla:
```
```bash
wget https://www.postgresql.org/media/keys/ACCC4CF8.asc
apt-key add ACCC4CF8.asc
```
y finalmente instalar postgresql
```
```bash
apt-get update
apt-get install postgresql-9.4 postgresql-server-dev-9.4 postgresql-contrib-9.4
```
Para el correcto funcionamiento de Consul Democracy, necesitas confgurar un usuario para tu base de datos. Como ejemplo, crearemos un usuario llamado "consul":
```
```bash
su - postgres
createuser consul --createdb --superuser --pwprompt

View File

@@ -113,7 +113,7 @@ Añade el complemento (add-on) de SendGrid en Heroku. Esto creará una cuenta de
Añade el siguiente código a `config/secrets.yml`, en la sección `production:`:
```
```yaml
mailer_delivery_method: :smtp
smtp_settings:
:address: "smtp.sendgrid.net"

View File

@@ -26,15 +26,15 @@ En la sección "Añadir claves SSH" pulse el botón "Nueva clave SSH".
En la ventana emergente que aparece es necesario copiar y pegar la clave pública que [generamos en el paso anterior](generating_ssh_key.md). Para ver el contenido de esta clave en la ventana del terminal, escriba:
```
cat ~/.ssh/id_rsa.pub
```
```bash
cat ~/.ssh/id_rsa.pub
```
Debería ver un texto como este:
```
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDy/BXU0OsK8KLLXpd7tVnqDU+d4ZS2RHQmH+hv0BFFdP6PmUbKdBDigRqG6W3QBexB2DpVcb/bmHlfhzDlIHJn/oki+SmUYLSWWTWuSeF/1N7kWf9Ebisk6hiBkh5+i0oIJYvAUsNm9wCayQ+i3U3NjuB25HbgtyjR3jDPIhmg1xv0KZ8yeVcU+WJth0pIvwq+t4vlZbwhm/t2ah8O7hWnbaGV/MZUcj0/wFuiad98yk2MLGciV6XIIq+MMIEWjrrt933wAgzEB8vgn9acrDloJNvqx25uNMpDbmoNXJ8+/P3UDkp465jmejVd/6bRaObXplu2zTv9wDO48ZpsaACP your_username@your_computer_name
```
```text
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDy/BXU0OsK8KLLXpd7tVnqDU+d4ZS2RHQmH+hv0BFFdP6PmUbKdBDigRqG6W3QBexB2DpVcb/bmHlfhzDlIHJn/oki+SmUYLSWWTWuSeF/1N7kWf9Ebisk6hiBkh5+i0oIJYvAUsNm9wCayQ+i3U3NjuB25HbgtyjR3jDPIhmg1xv0KZ8yeVcU+WJth0pIvwq+t4vlZbwhm/t2ah8O7hWnbaGV/MZUcj0/wFuiad98yk2MLGciV6XIIq+MMIEWjrrt933wAgzEB8vgn9acrDloJNvqx25uNMpDbmoNXJ8+/P3UDkp465jmejVd/6bRaObXplu2zTv9wDO48ZpsaACP your_username@your_computer_name
```
Seleccione y copie todo el texto y péguelo en la ventana emergente de la siguiente manera:

View File

@@ -91,7 +91,7 @@ POSTGRES_PASSWORD=password docker-compose up -d database
Ahora podemos crear la base de datos e introducir datos de prueba:
```
```bash
POSTGRES_PASSWORD=password docker-compose run app rake db:create db:migrate
POSTGRES_PASSWORD=password docker-compose run app rake db:dev_seed
```

View File

@@ -4,15 +4,15 @@ Estas instrucciones le ayudarán a generar una clave pública con la que podrá
En la ventana del terminal, escriba:
```
ssh-keygen
```
```bash
ssh-keygen
```
Cuando se le pida el archivo en el que guardar la clave, sólo tiene que pulsar ENTER para dejar el valor predeterminado. Cuando se le pida una frase de contraseña, pulse ENTER de nuevo para dejarla vacía. Al final debería ver un mensaje como este:
```
Your identification has been saved in /your_home/.ssh/id_rsa.
Your public key has been saved in /your_home/.ssh/id_rsa.pub.
```
```text
Your identification has been saved in /your_home/.ssh/id_rsa.
Your public key has been saved in /your_home/.ssh/id_rsa.pub.
```
Tome nota de la ubicación del archivo **id_rsa.pub**, porque necesitará el contenido de este archivo más adelante.

View File

@@ -22,7 +22,7 @@ OS X ya viene con una versión preinstalada de ruby, pero es bastante vieja y en
## Bundler
```
```bash
gem install bundler
```
@@ -34,7 +34,7 @@ Para instalar Node, puedes usar [n](https://github.com/tj/n)
Ejecuta el siguiente comando en tu terminal:
```
```bash
curl -L https://git.io/n-install | bash -s -- -y lts
```
@@ -42,19 +42,19 @@ Y este instalará automáticamente la versión LTS (_Long Term Support_, inglés
## PostgreSQL (>=9.4)
```
```bash
brew install postgres
```
Una vez instalado es necesario *inicializar* la instalación:
```
```bash
initdb /usr/local/var/postgres
```
Ahora vamos a configurar algunos aspectos del usuario por defecto. Primero iniciamos el servidor de postgres con:
```
```bash
postgres -D /usr/local/var/postgres
```
@@ -62,7 +62,7 @@ Llegados a este punto se supone que tenemos postgres correctamente instalado y s
Si ejecutamos `psql` accederemos a la consola de postgres con el usuario por defecto. Probablemente fallará porque es necesario que de antemano exista una base de datos por defecto para dicho usuario. Podemos crearla ejecutando sobre la terminal:
```
```bash
createdb 'tu_nombre_de_usuario'
```
@@ -70,13 +70,13 @@ Si ahora ejecutamos `psql` de nuevo deberíamos poder acceder correctamente a la
En el caso de que quieras asignarte una contraseña puedes hacerlo desde la consola de postgres con:
```
```sql
ALTER USER tu_nombre_usuario WITH PASSWORD 'tu_contraseña';
```
Ahora vamos a crear el usuario *consul*, que es el que utiliza la aplicación. Ejecuta sobre la consola de postgres:
```
```sql
CREATE ROLE consul WITH PASSWORD '000';
ALTER ROLE consul WITH SUPERUSER;
ALTER ROLE consul WITH login;
@@ -84,25 +84,25 @@ ALTER ROLE consul WITH login;
Si en algún momento durante la instalación de PostgreSQL y sospechas que te has equivocado y deseas desinstalarlo y volver a empezar desde cero:
```
```bash
brew uninstall postgres
```
También tendrás que borrar el siguiente directorio para que no de conflictos cuando intentes volver a instalarlo (fuente: [gist.github.com/lxneng/741932](https://gist.github.com/lxneng/741932)):
```
```bash
rm -rf /usr/local/var/postgres
```
## ChromeDriver
```
```bash
brew install chromedriver
```
## Imagemagick
```
```bash
brew install imagemagick
```

View File

@@ -10,7 +10,7 @@ La estructura de directorios que se crea a continuación está pensada para usar
En primer lugar, crea el directorio principal, clona el repositorio y crea los subdirectorios necesarios:
```
```bash
mkdir consul && cd consul
git clone --mirror https://github.com/consuldemocracy/consuldemocracy.git repo
mkdir releases shared
@@ -22,7 +22,7 @@ mkdir -p shared/public/assets shared/public/system shared/public/ckeditor_assets
Crea una primera carpeta en "releases" a partir del repositorio, junto con un enlace simbólico a la versión actual (sustituye `<latest_consul_stable_version>` por el número de la última versión estable de Consul Democracy, como 1.3.1 o 1.4.1):
```
```bash
cd repo
git archive <latest_consul_stable_version> | tar -x -f - -C ../releases/first
cd ..
@@ -33,7 +33,7 @@ ln -s releases/first current
Instala las gemas de las que depende Consul Democracy:
```
```bash
cd releases/first
bundle install --path ../../shared/bundle --without development test
cd ../..
@@ -43,7 +43,7 @@ cd ../..
Genera los ficheros `database.yml` y `secrets.yml`:
```
```bash
cp current/config/secrets.yml.example shared/config/secrets.yml
cp current/config/database.yml.example shared/config/database.yml
cd releases/first/config
@@ -56,7 +56,7 @@ Edita el fichero `shared/config/database.yml`, rellenando `username` y `password
Ahora generamos una clave secreta:
```
```bash
cd current
bin/rake secret RAILS_ENV=production
cd ..
@@ -64,7 +64,7 @@ cd ..
Copia la clave generada y edita el fichero `shared/config/secrets.yml`; en la sección `production`, cambia los siguientes datos:
```
```yaml
secret_key_base: introduce_la_clave_secreta_que_acabas_de_generar
server_name: introduce_tu_dominio
```
@@ -75,7 +75,7 @@ Si no tienes un certificado SSL, cambia además `force_ssl: true` por `force_ssl
Crea una base de datos, genera los datos necesarios para que la aplicación funcione y compila los ficheros de CSS y JavaScript:
```
```bash
cd current
bin/rake db:migrate RAILS_ENV=production
bin/rake db:seed RAILS_ENV=production
@@ -86,7 +86,7 @@ Crea una base de datos, genera los datos necesarios para que la aplicación func
Y, por último, inicia el servidor de Rails:
```
```bash
bin/rails s -e production
```

View File

@@ -61,13 +61,13 @@ sudo -u postgres createuser consul --createdb --superuser --pwprompt
Para asegurarse que se utiliza la codificación con UTF-8, crea un archivo:
```
```bash
sudo nano /etc/profile.d/lang.sh
```
Añade las siguientes líneas:
```
```bash
export LANGUAGE="en_US.UTF-8"
export LANG="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
@@ -75,10 +75,12 @@ export LC_ALL="en_US.UTF-8"
Reconfigura Postgres para utilizar la codificación UTF-8:
`````
```bash
sudo su - postgres
psql
```
```sql
update pg_database set datistemplate=false where datname='template1';
drop database Template1;
create database template1 with owner=postgres encoding='UTF-8'
@@ -87,7 +89,7 @@ update pg_database set datistemplate=true where datname='template1';
\q
exit
`````
```
## Imagemagick

View File

@@ -12,25 +12,25 @@ Para acceder a la aplicación a través del navegador en la url `localhost:3000`
Abra el archivo de configuración de Vagrant:
```
```bash
nano Vagranfile
```
Encuentre esta línea:
```
```ruby
# config.vm.network "forwarded_port", guest: 80, host: 8080
```
Cámbiela por esta:
```
```ruby
config.vm.network "forwarded_port", guest: 3000, host: 3000
```
Recargue la máquina virtual:
```
```bash
vagrant reload
```
@@ -38,7 +38,7 @@ vagrant reload
En su máquina virtual, debe ejecutar la aplicación enlanzándola a su IP local:
```
```bash
bin/rails s -b 0.0.0.0
```