Documente Academic
Documente Profesional
Documente Cultură
How to install Rails, create a new Rails application, and connect your
application to a database.
Chapters
1. Guide Assumptions
2. What is Rails?
4. Hello, Rails!
Starting up the Web Server
https://guides.rubyonrails.org/getting_started.html 1/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
Creating articles
Running a Migration
Showing Articles
Adding links
Updating Articles
Deleting Articles
Associating Models
Generating a Controller
7. Refactoring
Rendering Partial Collections
8. Deleting Comments
Deleting Associated Objects
9. Security
Basic Authentication
1 Guide Assumptions
This guide is designed for beginners who want to get started with a Rails application from scratch. It does
not assume that you have any prior experience with Rails.
Rails is a web application framework running on the Ruby programming language. If you have no prior
experience with Ruby, you will find a very steep learning curve diving straight into Rails. There are several
curated lists of online resources for learning Ruby:
Be aware that some resources, while still excellent, cover versions of Ruby as old as 1.6, and commonly
1.8, and will not include some syntax that you will see in day-to-day development with Rails.
2 What is Rails?
Rails is a web application development framework written in the Ruby programming language. It is
designed to make programming web applications easier by making assumptions about what every
developer needs to get started. It allows you to write less code while accomplishing more than many other
languages and frameworks. Experienced Rails developers also report that it makes web application
development more fun.
Rails is opinionated software. It makes the assumption that there is a "best" way to do things, and it's
designed to encourage that way - and in some cases to discourage alternatives. If you learn "The Rails
Way" you'll probably discover a tremendous increase in productivity. If you persist in bringing old habits
from other languages to your Rails development, and trying to use patterns you learned elsewhere, you
may have a less happy experience.
Don't Repeat Yourself: DRY is a principle of software development which states that "Every
piece of knowledge must have a single, unambiguous, authoritative representation within a
system." By not writing the same information over and over again, our code is more maintainable,
more extensible, and less buggy.
Convention Over Configuration: Rails has opinions about the best way to do many things in a
web application, and defaults to this set of conventions, rather than require that you specify
minutiae through endless configuration files.
https://guides.rubyonrails.org/getting_started.html 3/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
By following along with this guide, you'll create a Rails project called blog, a (very) simple weblog. Before
you can start building the application, you need to make sure that you have Rails itself installed.
The examples below use $ to represent your terminal prompt in a UNIX-like OS, though it may have been
customized to appear differently. If you are using Windows, your prompt will look something like
c:\source_code>
Open up a command line prompt. On macOS open Terminal.app, on Windows choose "Run" from your
Start menu and type 'cmd.exe'. Any commands prefaced with a dollar sign $ should be run in the
command line. Verify that you have a current version of Ruby installed:
$ ruby -v
ruby 2.3.1p112
Rails requires Ruby version 2.2.2 or later. If the version number returned is less than that number, you'll
need to install a fresh copy of Ruby.
A number of tools exist to help you quickly install Ruby and Ruby on Rails on your system. Windows users
can use Rails Installer, while macOS users can use Tokaido. For more installation methods for most
Operating Systems take a look at ruby-lang.org.
If you are working on Windows, you should also install the Ruby Installer Development Kit.
You will also need an installation of the SQLite3 database. Many popular UNIX-like OSes ship with an
acceptable version of SQLite3. On Windows, if you installed Rails through Rails Installer, you already have
SQLite installed. Others can find installation instructions at the SQLite3 website. Verify that it is correctly
installed and in your PATH:
https://guides.rubyonrails.org/getting_started.html 4/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
$ sqlite3 --version
To verify that you have everything installed correctly, you should be able to run the following:
$ rails --version
To use this generator, open a terminal, navigate to a directory where you have rights to create files, and
type:
This will create a Rails application called Blog in a blog directory and install the gem dependencies that
are already mentioned in Gemfile using bundle install.
If you're using Windows Subsystem for Linux then there are currently some limitations on file system
notifications that mean you should disable the spring and listen gems which you can do by running
https://guides.rubyonrails.org/getting_started.html 5/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
You can see all of the command line options that the Rails application builder accepts by running rails
new -h.
$ cd blog
The blog directory has a number of auto-generated files and folders that make up the structure of a Rails
application. Most of the work in this tutorial will happen in the app folder, but here's a basic rundown on the
function of each of the files and folders that Rails created by default:
File/Folder Purpose
Contains the controllers, models, views, helpers, mailers, channels, jobs and assets
app/
for your application. You'll focus on this folder for the remainder of this guide.
Contains the rails script that starts your app and can contain other scripts you use to
bin/
setup, update, deploy or run your application.
Configure your application's routes, database, and more. This is covered in more
config/
detail in Configuring Rails Applications.
Rack configuration for Rack based servers used to start the application. For more
config.ru
information about Rack, see the Rack website.
db/ Contains your current database schema, as well as the database migrations.
These files allow you to specify what gem dependencies are needed for your Rails
Gemfile
application. These files are used by the Bundler gem. For more information about
Gemfile.lock
Bundler, see the Bundler website.
https://guides.rubyonrails.org/getting_started.html 6/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
File/Folder Purpose
This file allows you to specify what npm dependencies are needed for your Rails
package.json application. This file is used by Yarn. For more information about Yarn, see the Yarn
website.
public/ The only folder seen by the world as-is. Contains static files and compiled assets.
This file locates and loads tasks that can be run from the command line. The task
definitions are defined throughout the components of Rails. Rather than changing
Rakefile
Rakefile, you should add your own tasks by adding files to the lib/tasks directory
of your application.
This is a brief instruction manual for your application. You should edit this file to tell
README.md
others what your application does, how to set it up, and so on.
Unit tests, fixtures, and other test apparatus. These are covered in Testing Rails
test/
Applications.
A place for all third-party code. In a typical Rails application this includes vendored
vendor/
gems.
This file tells git which files (or patterns) it should ignore. See GitHub - Ignoring files
.gitignore
for more info about ignoring files.
4 Hello, Rails!
To begin with, let's get some text up on screen quickly. To do this, you need to get your Rails application
server running.
You actually have a functional Rails application already. To see it, you need to start a web server on your
development machine. You can do this by running the following in the blog directory:
$ bin/rails server
If you are using Windows, you have to pass the scripts under the bin folder directly to the Ruby interpreter
e.g. ruby bin\rails server.
Compiling CoffeeScript and JavaScript asset compression requires you have a JavaScript runtime
available on your system, in the absence of a runtime you will see an execjs error during asset
compilation. Usually macOS and Windows come with a JavaScript runtime installed. Rails adds the
mini_racer gem to the generated Gemfile in a commented line for new apps and you can uncomment if
you need it. therubyrhino is the recommended runtime for JRuby users and is added by default to the
Gemfile in apps generated under JRuby. You can investigate all the supported runtimes at ExecJS.
This will fire up Puma, a web server distributed with Rails by default. To see your application in action,
open a browser window and navigate to http://localhost:3000. You should see the Rails default
information page:
To stop the web server, hit Ctrl+C in the terminal window where it's running. To verify the server has
stopped you should see your command prompt cursor again. For most UNIX-like systems including
macOS this will be a dollar sign $. In development mode, Rails does not generally require you to restart
the server; changes you make in files will be automatically picked up by the server.
The "Welcome aboard" page is the smoke test for a new Rails application: it makes sure that you have
your software configured correctly enough to serve a page.
A controller's purpose is to receive specific requests for the application. Routing decides which controller
receives which requests. Often, there is more than one route to each controller, and different routes can be
served by different actions. Each action's purpose is to collect information to provide it to a view.
A view's purpose is to display this information in a human readable format. An important distinction to
https://guides.rubyonrails.org/getting_started.html 8/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
make is that it is the controller, not the view, where information is collected. The view should just display
that information. By default, view templates are written in a language called eRuby (Embedded Ruby)
which is processed by the request cycle in Rails before being sent to the user.
https://guides.rubyonrails.org/getting_started.html 9/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
To create a new controller, you will need to run the "controller" generator and tell it you want a controller
called "Welcome" with an action called "index", just like this:
create app/controllers/welcome_controller.rb
route get 'welcome/index'
invoke erb
create app/views/welcome
create app/views/welcome/index.html.erb
invoke test_unit
create test/controllers/welcome_controller_test.rb
invoke helper
create app/helpers/welcome_helper.rb
invoke test_unit
invoke assets
invoke coffee
create app/assets/javascripts/welcome.coffee
invoke scss
create app/assets/stylesheets/welcome.scss
Open the app/views/welcome/index.html.erb file in your text editor. Delete all of the existing code in
the file, and replace it with the following single line of code:
<h1>Hello, Rails!</h1>
https://guides.rubyonrails.org/getting_started.html 10/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
Now that we have made the controller and view, we need to tell Rails when we want "Hello, Rails!" to show
up. In our case, we want it to show up when we navigate to the root URL of our site,
http://localhost:3000. At the moment, "Welcome aboard" is occupying that spot.
Next, you have to tell Rails where your actual home page is located.
Rails.application.routes.draw do
get 'welcome/index'
Este es el archivo de enrutamiento de su aplicación que contiene entradas en un DSL especial (lenguaje
específico del dominio) que le dice a Rails cómo conectar las solicitudes entrantes con los controladores
y las acciones. Edite este archivo agregando la línea de código root 'welcome#index'. Debería verse
algo como lo siguiente:
Rails.application.routes.draw do
get 'welcome/index'
root 'welcome#index'
end
root 'welcome#index'le dice a Rails que asigne solicitudes a la raíz de la aplicación a la acción de
índice del controlador de bienvenida y get 'welcome/index' le dice a Rails que asigne las solicitudes a
http: // localhost: 3000 / welcome / index a la acción de índice del controlador de bienvenida. Esto se
creó anteriormente cuando ejecutó el generador del controlador ( bin/rails generate controller
Welcome index).
Para obtener más información acerca del enrutamiento, consulte Rails Routing from the Outside In .
5 Comenzando a correr
Ahora que ha visto cómo crear un controlador, una acción y una vista, creemos algo con un poco más de
sustancia.
En la aplicación Blog, ahora creará un nuevo recurso . Un recurso es el término utilizado para una
colección de objetos similares, como artículos, personas o animales. Puede crear, leer, actualizar y
destruir elementos para un recurso y estas operaciones se conocen como operaciones CRUD .
Rails proporciona un resourcesmétodo que se puede usar para declarar un recurso REST estándar.
Necesita agregar el recurso de artículo al config/routes.rbpara que el archivo se vea de la siguiente
manera:
Rails.application.routes.draw do
get 'welcome/index'
resources :articles
root 'welcome#index'
end
Si se ejecuta bin/rails routes, verá que tiene rutas definidas para todas las acciones RESTful
estándar. El significado de la columna de prefijo (y otras columnas) se verá más adelante, pero por ahora
observe que Rails ha inferido la forma singular articley hace un uso significativo de la distinción.
$ bin/rails routes
Prefix Verb URI Pattern Controller#Action
welcome_index GET /welcome/index(.:format) welcome#index
articles GET /articles(.:format) articles#index
POST /articles(.:format) articles#create
new_article GET /articles/new(.:format) articles#new
edit_article GET /articles/:id/edit(.:format) articles#edit
article GET /articles/:id(.:format) articles#show
PATCH /articles/:id(.:format) articles#update
PUT /articles/:id(.:format) articles#update
DELETE /articles/:id(.:format) articles#destroy
https://guides.rubyonrails.org/getting_started.html 12/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
root GET / welcome#index
En la siguiente sección, agregará la capacidad de crear nuevos artículos en su aplicación y poder verlos.
Esta es la "C" y la "R" de CRUD: crea y lee. La forma de hacer esto se verá así:
Un controlador es simplemente una clase que se define para heredar ApplicationController. Es dentro
de esta clase que definirás los métodos que se convertirán en las acciones de este controlador. Estas
acciones realizarán operaciones CRUD en los artículos dentro de nuestro sistema.
Hay public, privatey protectedmétodos en Ruby, pero sólo los publicmétodos pueden ser acciones
de los controladores. Para obtener más detalles, consulte Programming Ruby .
Si actualiza http: // localhost: 3000 / articles / new ahora, obtendrá un nuevo error:
Este
error
indica que Rails no puede encontrar la newacción dentro del ArticlesControllerque acaba de generar.
Esto se debe a que cuando los controladores se generan en Rails, están vacíos de manera
predeterminada, a menos que le indique las acciones deseadas durante el proceso de generación.
Para definir manualmente una acción dentro de un controlador, todo lo que necesita hacer es definir un
nuevo método dentro del controlador. Abra app/controllers/articles_controller.rby dentro de la
ArticlesController clase, defina el newmétodo para que su controlador se vea así:
Con el newmétodo definido en ArticlesController, si actualiza http: // localhost: 3000 / articles / new
verá otro error:
Obtiene este error ahora porque Rails espera que acciones simples como esta tengan vistas asociadas a
ellas para mostrar su información. Sin vista disponible, Rails generará una excepción.
ArticlesController # new no tiene una plantilla para este formato de solicitud y variante. request.formats:
["text / html"] request.variant: [] ¡NOTA! Para solicitudes XHR / Ajax o API, esta acción normalmente
respondería con 204 Sin contenido: una pantalla blanca vacía. Dado que lo está cargando en un
navegador web, suponemos que esperaba representar realmente una plantilla, no ... nada, por lo que
estamos mostrando un error para ser extra claro. Si espera 204 Sin contenido, continúe. Eso es lo que
obtendrás de una solicitud XHR o API. Dale un tiro.
¡Eso es bastante texto! Repasemos rápidamente y comprendamos qué significa cada parte de ella.
La primera parte identifica qué plantilla falta. En este caso, es la articles/newplantilla. Rails primero
buscará esta plantilla. Si no se encuentra, intentará cargar una plantilla llamada application/new. Busca
uno aquí porque ArticlesControllerhereda de ApplicationController.
La siguiente parte del mensaje contiene request.formatsque especifica el formato de la plantilla que se
servirá en respuesta. Está configurado text/htmlcomo solicitamos esta página a través del navegador,
https://guides.rubyonrails.org/getting_started.html 15/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
por lo que Rails está buscando una plantilla HTML. request.variantespecifica qué tipo de dispositivos
físicos recibiría la respuesta y ayuda a Rails a determinar qué plantilla usar en la respuesta. Está vacío
porque no se ha proporcionado información.
La plantilla más simple que funcionaría en este caso sería una ubicada en
app/views/articles/new.html.erb. La extensión de este nombre de archivo es importante: la primera
extensión es el formato de la plantilla, y la segunda extensión es el controlador que se usará para
representar la plantilla. Rails está intentando encontrar una plantilla llamada articles/newdentro
app/viewsde la aplicación. El formato para esta plantilla solo puede ser htmly es el controlador
predeterminado para HTML erb. Rails usa otros controladores para otros formatos. builderHandler se
usa para crear plantillas XML y coffeeHandler usa CoffeeScript para crear plantillas de JavaScript. Como
quiera crear un nuevo formulario HTML, usará el ERBlenguaje diseñado para incrustar Ruby en HTML.
Por lo tanto, el archivo debe llamarse articles/new.html.erby debe ubicarse dentro del
app/viewsdirectorio de la aplicación.
<h1>New Article</h1>
Cuando actualice http: // localhost: 3000 / articles / new , verá que la página tiene un título. ¡La ruta, el
controlador, la acción y la vista ahora están funcionando armoniosamente! Es hora de crear el formulario
para un nuevo artículo.
https://guides.rubyonrails.org/getting_started.html 16/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
<p>
<%= form.label :text %><br>
<%= form.text_area :text %>
</p>
<p>
<%= form.submit %>
</p>
<% end %>
Si actualizas la página ahora, verás el mismo formulario de nuestro ejemplo anterior. ¡Crear formularios en
Rails es realmente así de fácil!
Cuando llama form_with, le pasa un alcance de identificación para este formulario. En este caso, es el
símbolo :article. Esto le dice al form_with ayudante para qué es esta forma. Dentro del bloque para
este método, el FormBuilderobjeto - representado por form- se usa para construir dos etiquetas y dos
campos de texto, uno para el título y el texto de un artículo. Por último, una llamada a submitla
formobjeto creará un botón de envío del formulario.
Sin embargo, hay un problema con esta forma. Si inspecciona el código HTML que se genera, al ver el
origen de la página, verá que action apunta hacia el atributo del formulario /articles/new. Este es un
problema porque esta ruta va directamente a la página en la que se encuentra en este momento, y esa
ruta solo debe usarse para mostrar el formulario de un nuevo artículo.
El formulario necesita usar una URL diferente para ir a otro lugar. Esto se puede hacer simplemente con la
:urlopción de form_with. Por lo general, en Rails, la acción que se utiliza para envíos de formularios
nuevos como este se llama "crear", por lo que el formulario debe apuntar a esa acción.
<%= form_with scope: :article, url: articles_path, local: true do |form| %>
En este ejemplo, el articles_pathasistente se pasa a la :urlopción. Para ver qué hará Rails con esto,
volvemos a mirar el resultado de bin/rails routes:
https://guides.rubyonrails.org/getting_started.html 17/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
$ bin/rails routes
Prefix Verb URI Pattern Controller#Action
welcome_index GET /welcome/index(.:format) welcome#index
articles GET /articles(.:format) articles#index
POST /articles(.:format) articles#create
new_article GET /articles/new(.:format) articles#new
edit_article GET /articles/:id/edit(.:format) articles#edit
article GET /articles/:id(.:format) articles#show
PATCH /articles/:id(.:format) articles#update
PUT /articles/:id(.:format) articles#update
DELETE /articles/:id(.:format) articles#destroy
root GET / welcome#index
El articles_pathayudante le dice a Rails que apunte el formulario al patrón URI asociado con el
articlesprefijo; y el formulario enviará (por defecto) una POSTsolicitud a esa ruta. Esto está asociado con
la createacción del controlador actual, el ArticlesController.
Con el formulario y su ruta asociada definida, podrá completar el formulario y luego hacer clic en el botón
enviar para comenzar el proceso de creación de un nuevo artículo, así que adelante y haga eso. Cuando
envíe el formulario, debería ver un error familiar:
Ahora necesita crear la createacción dentro del ArticlesControllerpara que esto funcione.
https://guides.rubyonrails.org/getting_started.html 18/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
como se muestra:
def create
end
end
Si vuelve a enviar el formulario ahora, es posible que no vea ningún cambio en la página. ¡No te
preocupes! Esto se debe a que Rails de forma predeterminada devuelve una 204 No Contentrespuesta
para una acción si no especificamos cuál debería ser la respuesta. Acabamos de agregar la createacción
pero no especificamos nada sobre cómo debería ser la respuesta. En este caso, la createacción debería
guardar nuestro nuevo artículo en la base de datos.
Cuando se envía un formulario, los campos del formulario se envían a Rails como parámetros . Estos
parámetros pueden ser referenciados dentro de las acciones del controlador, típicamente para realizar
una tarea en particular. Para ver cómo son estos parámetros, cambie la createacción a esto:
def create
render plain: params[:article].inspect
end
El rendermétodo aquí es tomar un hash muy simple con una clave de :plainy un valor de
params[:article].inspect. El paramsmétodo es el objeto que representa los parámetros (o campos)
que provienen del formulario. El params método devuelve un ActionController::Parametersobjeto, que
le permite acceder a las claves del hash utilizando cadenas o símbolos. En esta situación, los únicos
parámetros que importan son los de la forma.
Asegúrese de tener una comprensión firme del paramsmétodo, ya que lo usará con bastante regularidad.
Consideremos un ejemplo de URL: http://www.example.com/?username=dhh&email=dhh@email.com
. En esta URL, params[:username]sería igual a "dhh" e params[:email]igualaría a " dhh@email.com ".
Si vuelves a enviar el formulario una vez más, verás algo que se parece a lo siguiente:
https://guides.rubyonrails.org/getting_started.html 19/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
Esta acción ahora muestra los parámetros para el artículo que viene del formulario. Sin embargo, esto no
es realmente tan útil. Sí, puede ver los parámetros, pero no se está haciendo nada en particular con ellos.
Con ese comando le dijimos a los carriles que queremos un Articlemodelo, junto con un título atributo
de tipo cadena, y un texto de atributo de tipo texto. Esos atributos se agregan automáticamente a la
articles tabla en la base de datos y se asignan al Articlemodelo.
Rails respondió creando un montón de archivos. Por ahora, solo nos interesa app/models/article.rby
db/migrate/20140120191729_create_articles.rb (su nombre podría ser un poco diferente). Este
último es responsable de crear la estructura de la base de datos, que es lo que veremos a continuación.
Active Record es lo suficientemente inteligente como para mapear automáticamente los nombres de las
columnas a los atributos del modelo, lo que significa que no tiene que declarar atributos dentro de los
modelos de Rails, ya que esto será hecho automáticamente por Active Record.
t.timestamps
end
end
end
La migración anterior crea un método llamado al changeque se llamará cuando ejecute esta migración. La
acción definida en este método también es reversible, lo que significa que Rails sabe cómo revertir el
cambio realizado por esta migración, en caso de que desee revertirla más tarde. Cuando ejecuta esta
migración, creará una articlestabla con una columna de cadena y una columna de texto. También crea
dos campos de marca de tiempo para permitir a Rails rastrear la creación de artículos y los tiempos de
actualización.
Para obtener más información acerca de las migraciones, consulte Migraciones de registros activos .
En este punto, puede usar un comando bin / rails para ejecutar la migración:
$ bin/rails db:migrate
Rails ejecutará este comando de migración y le dirá que creó la tabla Artículos.
== CreateArticles: migrating
==================================================
-- create_table(:articles)
-> 0.0019s
== CreateArticles: migrated (0.0020s)
=========================================
https://guides.rubyonrails.org/getting_started.html 21/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
Como está trabajando en el entorno de desarrollo de forma predeterminada, este comando se aplicará a
la base de datos definida en la developmentsección de su config/database.ymlarchivo. Si desea
ejecutar las migraciones en otro entorno, por ejemplo, en la producción, se debe pasar de forma explícita
cuando se invoca el comando: bin/rails db:migrate RAILS_ENV=production.
def create
@article = Article.new(params[:article])
@article.save
redirect_to @article
end
Esto es lo que sucede: cada modelo de Rails se puede inicializar con sus respectivos atributos, que se
asignan automáticamente a las columnas de la base de datos respectivas. En la primera línea hacemos
exactamente eso (recuerde que params[:article]contiene los atributos que nos interesan). Luego,
@article.savees responsable de guardar el modelo en la base de datos. Finalmente, redirigimos al
usuario a la showacción, que definiremos más adelante.
Es posible que se pregunte por qué la entrada está Aen Article.newmayúscula arriba, mientras que la
mayoría de las otras referencias a los artículos en esta guía han usado minúsculas. En este contexto, nos
estamos refiriendo a la clase nombrada Articleque se define en app/models/article.rb. Los nombres
de clase en Ruby deben comenzar con una letra mayúscula.
Como veremos más adelante, @article.savedevuelve un booleano que indica si el artículo fue guardado
o no.
Si ahora va a http: // localhost: 3000 / articles / new , casi podrá crear un artículo. ¡Intentalo! Debería
obtener un error que se ve así:
https://guides.rubyonrails.org/getting_started.html 22/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
Rails tiene
varias
características
de seguridad
que lo ayudan
a escribir
aplicaciones
seguras, y
ahora se
encuentra con
uno de ellos.
Este se llama
parámetros
fuertes , lo que
requiere que le digamos a Rails exactamente qué parámetros están permitidos en nuestras acciones de
controlador.
¿Por qué tienes que molestarte? La capacidad de capturar y asignar automáticamente todos los
parámetros del controlador a su modelo de una sola vez facilita el trabajo del programador, pero esta
conveniencia también permite el uso malicioso. ¿Qué pasa si una solicitud al servidor se diseñó para
parecerse a un nuevo formulario de artículo enviado pero también incluyó campos adicionales con valores
que violaron la integridad de su aplicación? Serían 'asignados en masa' en su modelo y luego en la base
de datos junto con las cosas buenas, lo que podría romper su aplicación o algo peor.
Tenemos que incluir en la lista blanca nuestros parámetros de controlador para evitar la asignación de
masa incorrecta. En este caso, queremos permitir y requerir los parámetros titley textpara el uso válido
de create. La sintaxis para esto introduce requirey permit. El cambio involucrará una línea en la
createacción:
Esto a menudo se factoriza en su propio método para que pueda ser reutilizado por múltiples acciones en
el mismo controlador, por ejemplo createy update. Más allá de los problemas de asignación masiva, el
método a menudo se hace privatepara asegurarse de que no se puede llamar fuera de su contexto
previsto. Aquí está el resultado:
https://guides.rubyonrails.org/getting_started.html 23/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
def create
@article = Article.new(article_params)
@article.save
redirect_to @article
end
private
def article_params
params.require(:article).permit(:title, :text)
end
Para obtener más información, consulte la referencia anterior y este artículo de blog sobre Parámetros
fuertes .
Como hemos visto en la salida de bin/rails routes, la ruta para la showacción es la siguiente:
La sintaxis especial :idle dice a rails que esta ruta espera un :id parámetro, que en nuestro caso será el
id del artículo.
Una práctica frecuente es colocar las acciones CRUD estándar en cada controlador en el siguiente orden:
index, show, new, edit, create, update y destroy. Puede usar cualquier orden que elija, pero tenga en
cuenta que estos son métodos públicos; como se mencionó anteriormente en esta guía, deben colocarse
antes de declarar la privatevisibilidad en el controlador.
https://guides.rubyonrails.org/getting_started.html 24/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
def new
end
Un par de cosas a anotar. Usamos Article.findpara encontrar el artículo que nos interesa, pasando
params[:id]para obtener el :idparámetro de la solicitud. También usamos una variable de instancia (con
prefijo @) para mantener una referencia al objeto del artículo. Hacemos esto porque Rails pasará todas las
variables de instancia a la vista.
<p>
<strong>Title:</strong>
<%= @article.title %>
</p>
<p>
<strong>Text:</strong>
<%= @article.text %>
</p>
Con este cambio, finalmente debería ser capaz de crear nuevos artículos. Visita http: // localhost: 3000 /
articles / new y pruébalo!
https://guides.rubyonrails.org/getting_started.html 25/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
articles GET /articles(.:format) articles#index
def show
@article = Article.find(params[:id])
end
def new
end
<h1>Listing articles</h1>
<table>
<tr>
<th>Title</th>
<th>Text</th>
<th></th>
</tr>
https://guides.rubyonrails.org/getting_started.html 26/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
</table>
Ahora, si va a http: // localhost: 3000 / articles , verá una lista de todos los artículos que ha creado.
<h1>Hello, Rails!</h1>
<%= link_to 'My Blog', controller: 'articles' %>
Agreguemos enlaces a las otras vistas también, comenzando con agregar este enlace de "Artículo nuevo"
app/views/articles/index.html.erb, colocándolo encima de la <table>etiqueta:
Este enlace le permitirá abrir el formulario que le permite crear un nuevo artículo.
Ahora, agregue otro enlace app/views/articles/new.html.erb, debajo del formulario, para volver a la
indexacción:
<%= form_with scope: :article, url: articles_path, local: true do |form| %>
...
<% end %>
https://guides.rubyonrails.org/getting_started.html 27/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
<p>
<strong>Title:</strong>
<%= @article.title %>
</p>
<p>
<strong>Text:</strong>
<%= @article.text %>
</p>
En el modo de desarrollo (que es lo que está trabajando de forma predeterminada), Rails vuelve a cargar
su aplicación con cada solicitud del navegador, por lo que no es necesario detener y reiniciar el servidor
web cuando se realiza un cambio.
No hay mucho en este archivo, pero tenga en cuenta que la Articleclase hereda de
ApplicationRecord. ApplicationRecordhereda de la ActiveRecord::Base cual proporciona una gran
cantidad de funcionalidad para sus modelos Rails de forma gratuita, incluidas operaciones básicas de
bases de datos CRUD (Crear, Leer, Actualizar, Destruir), validación de datos, así como soporte de
búsqueda sofisticado y la capacidad de relacionar múltiples modelos entre sí .
https://guides.rubyonrails.org/getting_started.html 28/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
Rails incluye métodos para ayudarlo a validar los datos que envía a los modelos. Abra el
app/models/article.rbarchivo y edítelo:
Estos cambios asegurarán que todos los artículos tengan un título de al menos cinco caracteres. Los
raíles pueden validar una variedad de condiciones en un modelo, incluida la presencia o unicidad de
columnas, su formato y la existencia de objetos asociados. Las validaciones están cubiertas en detalle en
Validaciones de registros activos .
Con la validación ahora en su lugar, cuando llame @article.savea un artículo no válido, se devolverá
false. Si app/controllers/articles_controller.rbvuelve a abrir , se dará cuenta de que no
verificamos el resultado de llamar @article.savedentro de la createacción. Si @article.savefalla en
esta situación, debemos mostrarle el formulario al usuario. Para ello, cambie el newy createacciones
dentro app/controllers/articles_controller.rbde estos:
def new
@article = Article.new
end
def create
@article = Article.new(article_params)
if @article.save
redirect_to @article
else
render 'new'
end
end
private
def article_params
params.require(:article).permit(:title, :text)
end
https://guides.rubyonrails.org/getting_started.html 29/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
La newacción ahora está creando una nueva variable de instancia llamada @article, y verá por qué eso
es en unos pocos momentos.
Si recarga http: // localhost: 3000 / articles / new e intenta guardar un artículo sin título, Rails lo enviará
de regreso al formulario, pero eso no es muy útil. Debe decirle al usuario que algo salió mal. Para hacer
eso, lo modificará app/views/articles/new.html.erbpara verificar si hay mensajes de error:
<%= form_with scope: :article, url: articles_path, local: true do |form| %>
<p>
<%= form.label :title %><br>
<%= form.text_field :title %>
</p>
<p>
<%= form.label :text %><br>
<%= form.text_area :text %>
</p>
<p>
<%= form.submit %>
</p>
https://guides.rubyonrails.org/getting_started.html 30/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
Algunas cosas están sucediendo. Verificamos si hay algún error con @article.errors.any?, y en ese
caso mostramos una lista de todos los errores @article.errors.full_messages.
pluralizees un ayudante de rieles que toma un número y una cadena como sus argumentos. Si el
número es mayor que uno, la cadena se pluralizará automáticamente.
Rails automáticamente envuelve los campos que contienen un error con un div con clase
field_with_errors. Puede definir una regla CSS para que destaque.
Ahora obtendrá un bonito mensaje de error al guardar un artículo sin título cuando intente hacer
justamente eso en el nuevo formulario de artículo http: // localhost: 3000 / articles / new :
El primer paso que tomaremos es agregar una editacción al ArticlesController, generalmente entre
las acciones newy create, como se muestra a continuación:
https://guides.rubyonrails.org/getting_started.html 31/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
def new
@article = Article.new
end
def edit
@article = Article.find(params[:id])
end
def create
@article = Article.new(article_params)
if @article.save
redirect_to @article
else
render 'new'
end
end
La vista contendrá un formulario similar al que usamos al crear nuevos artículos. Crea un archivo llamado
app/views/articles/edit.html.erby haz que se vea de la siguiente manera:
<h1>Edit article</h1>
<p>
<%= form.label :title %><br>
https://guides.rubyonrails.org/getting_started.html 32/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
<p>
<%= form.label :text %><br>
<%= form.text_area :text %>
</p>
<p>
<%= form.submit %>
</p>
This time we point the form to the update action, which is not defined yet but will be very soon.
Passing the article object to the method, will automagically create url for submitting the edited article form.
This option tells Rails that we want this form to be submitted via the PATCH HTTP method which is the
HTTP method you're expected to use to update resources according to the REST protocol.
The arguments to form_with could be model objects, say, model: @article which would cause the
helper to fill in the form with the fields of the object. Passing in a symbol scope (scope: :article) just
creates the fields but without anything filled into them. More details can be found in form_with
documentation.
def create
@article = Article.new(article_params)
if @article.save
redirect_to @article
else
render 'new'
end
end
https://guides.rubyonrails.org/getting_started.html 33/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
def update
@article = Article.find(params[:id])
if @article.update(article_params)
redirect_to @article
else
render 'edit'
end
end
private
def article_params
params.require(:article).permit(:title, :text)
end
The new method, update, is used when you want to update a record that already exists, and it accepts a
hash containing the attributes that you want to update. As before, if there was an error updating the article
we want to show the form back to the user.
We reuse the article_params method that we defined earlier for the create action.
It is not necessary to pass all the attributes to update. For example, if @article.update(title: 'A new
title') was called, Rails would only update the title attribute, leaving all other attributes untouched.
Finally, we want to show a link to the edit action in the list of all the articles, so let's add that now to
app/views/articles/index.html.erb to make it appear next to the "Show" link:
<table>
<tr>
<th>Title</th>
<th>Text</th>
<th colspan="2"></th>
</tr>
</tr>
<% end %>
</table>
And we'll also add one to the app/views/articles/show.html.erb template as well, so that there's also
an "Edit" link on an article's page. Add this at the bottom of the template:
...
<h2>
<%= pluralize(@article.errors.count, "error") %> prohibited
this article from being saved:
</h2>
<ul>
<% @article.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<p>
<%= form.label :title %><br>
<%= form.text_field :title %>
</p>
<p>
<%= form.label :text %><br>
<%= form.text_area :text %>
</p>
<p>
<%= form.submit %>
</p>
Everything except for the form_with declaration remained the same. The reason we can use this shorter,
simpler form_with declaration to stand in for either of the other forms is that @article is a resource
corresponding to a full set of RESTful routes, and Rails is able to infer which URI and method to use. For
more information about this use of form_with, see Resource-oriented style.
Now, let's update the app/views/articles/new.html.erb view to use this new partial, rewriting it
completely:
<h1>New article</h1>
<h1>Edit article</h1>
The delete routing method should be used for routes that destroy resources. If this was left as a typical
get route, it could be possible for people to craft malicious URLs like this:
We use the delete method for destroying resources, and this route is mapped to the destroy action
inside app/controllers/articles_controller.rb, which doesn't exist yet. The destroy method is
generally the last CRUD action in the controller, and like the other public CRUD actions, it must be placed
before any private or protected methods. Let's add it:
def destroy
@article = Article.find(params[:id])
@article.destroy
redirect_to articles_path
end
https://guides.rubyonrails.org/getting_started.html 37/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
def show
@article = Article.find(params[:id])
end
def new
@article = Article.new
end
def edit
@article = Article.find(params[:id])
end
def create
@article = Article.new(article_params)
if @article.save
redirect_to @article
else
render 'new'
end
end
def update
@article = Article.find(params[:id])
if @article.update(article_params)
redirect_to @article
else
render 'edit'
end
end
def destroy
https://guides.rubyonrails.org/getting_started.html 38/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
@article = Article.find(params[:id])
@article.destroy
redirect_to articles_path
end
private
def article_params
params.require(:article).permit(:title, :text)
end
end
You can call destroy on Active Record objects when you want to delete them from the database. Note
that we don't need to add a view for this action since we're redirecting to the index action.
<h1>Listing Articles</h1>
<%= link_to 'New article', new_article_path %>
<table>
<tr>
<th>Title</th>
<th>Text</th>
<th colspan="3"></th>
</tr>
https://guides.rubyonrails.org/getting_started.html 39/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
Here we're using link_to in a different way. We pass the named route as the second argument, and then
the options as another argument. The method: :delete and data: { confirm: 'Are you sure?' }
options are used as HTML5 attributes so that when the link is clicked, Rails will first show a confirm dialog
to the user, and then submit the link with method delete. This is done via the JavaScript file rails-ujs
which is automatically included in your application's layout (app/views/layouts/application.html.erb)
when you generated the application. Without this file, the confirmation dialog box won't appear.
Learn more about Unobtrusive JavaScript on Working With JavaScript in Rails guide.
Congratulations, you can now create, show, list, update and destroy articles.
In general, Rails encourages using resources objects instead of declaring routes manually. For more
information about routing, see Rails Routing from the Outside In.
https://guides.rubyonrails.org/getting_started.html 40/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
We're going to see the same generator that we used before when creating the Article model. This time
we'll create a Comment model to hold reference to an article. Run this command in your terminal:
File Purpose
This is very similar to the Article model that you saw earlier. The difference is the line belongs_to
:article, which sets up an Active Record association. You'll learn a little about associations in the next
section of this guide.
The (:references) keyword used in the bash command is a special data type for models. It creates a new
column on your database table with the provided model name appended with an _id that can hold integer
values. To get a better understanding, analyze the db/schema.rb file after running the migration.
https://guides.rubyonrails.org/getting_started.html 41/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
In addition to the model, Rails has also made a migration to create the corresponding database table:
t.timestamps
end
end
end
The t.references line creates an integer column called article_id, an index for it, and a foreign key
constraint that points to the id column of the articles table. Go ahead and run the migration:
$ bin/rails db:migrate
Rails is smart enough to only execute the migrations that have not already been run against the current
database, so in this case you will just see:
== CreateComments: migrating
=================================================
-- create_table(:comments)
-> 0.0115s
== CreateComments: migrated (0.0119s)
========================================
In fact, this is very close to the syntax that Rails uses to declare this association. You've already seen the
line of code inside the Comment model (app/models/comment.rb) that makes each comment belong to an
Article:
You'll need to edit app/models/article.rb to add the other side of the association:
These two declarations enable a good bit of automatic behavior. For example, if you have an instance
variable @article containing an article, you can retrieve all the comments belonging to that article as an
array using @article.comments.
For more information on Active Record associations, see the Active Record Associations guide.
resources :articles do
resources :comments
end
https://guides.rubyonrails.org/getting_started.html 43/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
This creates comments as a nested resource within articles. This is another part of capturing the
hierarchical relationship that exists between articles and comments.
File/Directory Purpose
Like with any blog, our readers will create their comments directly after reading the article, and once they
have added their comment, will be sent back to the article show page to see their comment now listed.
Due to this, our CommentsController is there to provide a method to create comments and delete spam
comments when they arrive.
So first, we'll wire up the Article show template (app/views/articles/show.html.erb) to let us make a
new comment:
https://guides.rubyonrails.org/getting_started.html 44/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
<p>
<strong>Title:</strong>
<%= @article.title %>
</p>
<p>
<strong>Text:</strong>
<%= @article.text %>
</p>
<h2>Add a comment:</h2>
<%= form_with(model: [ @article, @article.comments.build ], local: true) do
|form| %>
<p>
<%= form.label :commenter %><br>
<%= form.text_field :commenter %>
</p>
<p>
<%= form.label :body %><br>
<%= form.text_area :body %>
</p>
<p>
<%= form.submit %>
</p>
<% end %>
This adds a form on the Article show page that creates a new comment by calling the
CommentsController create action. The form_with call here uses an array, which will build a nested
route, such as /articles/1/comments.
end
private
def comment_params
params.require(:comment).permit(:commenter, :body)
end
end
You'll see a bit more complexity here than you did in the controller for articles. That's a side-effect of the
nesting that you've set up. Each request for a comment has to keep track of the article to which the
comment is attached, thus the initial call to the find method of the Article model to get the article in
question.
In addition, the code takes advantage of some of the methods available for an association. We use the
create method on @article.comments to create and save the comment. This will automatically link the
comment so that it belongs to that particular article.
Once we have made the new comment, we send the user back to the original article using the
article_path(@article) helper. As we have already seen, this calls the show action of the
ArticlesController which in turn renders the show.html.erb template. This is where we want the
comment to show, so let's add that to the app/views/articles/show.html.erb.
<p>
<strong>Title:</strong>
<%= @article.title %>
</p>
<p>
<strong>Text:</strong>
<%= @article.text %>
</p>
<h2>Comments</h2>
<% @article.comments.each do |comment| %>
<p>
<strong>Commenter:</strong>
<%= comment.commenter %>
</p>
<p>
https://guides.rubyonrails.org/getting_started.html 46/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
<strong>Comment:</strong>
<%= comment.body %>
</p>
<% end %>
<h2>Add a comment:</h2>
<%= form_with(model: [ @article, @article.comments.build ], local: true) do
|form| %>
<p>
<%= form.label :commenter %><br>
<%= form.text_field :commenter %>
</p>
<p>
<%= form.label :body %><br>
<%= form.text_area :body %>
</p>
<p>
<%= form.submit %>
</p>
<% end %>
Now you can add articles and comments to your blog and have them show up in the right places.
7 Refactoring
Now that we have articles and comments working, take a look at the
app/views/articles/show.html.erb template. It is getting long and awkward. We can use partials to
clean it up.
https://guides.rubyonrails.org/getting_started.html 47/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
<p>
<strong>Commenter:</strong>
<%= comment.commenter %>
</p>
<p>
<strong>Comment:</strong>
<%= comment.body %>
</p>
https://guides.rubyonrails.org/getting_started.html 48/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
<p>
<strong>Title:</strong>
<%= @article.title %>
</p>
<p>
<strong>Text:</strong>
<%= @article.text %>
</p>
<h2>Comments</h2>
<%= render @article.comments %>
<h2>Add a comment:</h2>
<%= form_with(model: [ @article, @article.comments.build ], local: true) do
|form| %>
<p>
<%= form.label :commenter %><br>
<%= form.text_field :commenter %>
</p>
<p>
<%= form.label :body %><br>
<%= form.text_area :body %>
</p>
<p>
<%= form.submit %>
</p>
<% end %>
This will now render the partial in app/views/comments/_comment.html.erb once for each comment that
is in the @article.comments collection. As the render method iterates over the @article.comments
collection, it assigns each comment to a local variable named the same as the partial, in this case comment
which is then available in the partial for us to show.
Let us also move that new comment section out to its own partial. Again, you create a file
app/views/comments/_form.html.erb containing:
<p>
<strong>Title:</strong>
<%= @article.title %>
</p>
<p>
<strong>Text:</strong>
<%= @article.text %>
</p>
<h2>Comments</h2>
<%= render @article.comments %>
<h2>Add a comment:</h2>
<%= render 'comments/form' %>
https://guides.rubyonrails.org/getting_started.html 50/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
The second render just defines the partial template we want to render, comments/form. Rails is smart
enough to spot the forward slash in that string and realize that you want to render the _form.html.erb file
in the app/views/comments directory.
The @article object is available to any partials rendered in the view because we defined it as an instance
variable.
8 Deleting Comments
Another important feature of a blog is being able to delete spam comments. To do this, we need to
implement a link of some sort in the view and a destroy action in the CommentsController.
<p>
<strong>Commenter:</strong>
<%= comment.commenter %>
</p>
<p>
<strong>Comment:</strong>
<%= comment.body %>
</p>
<p>
<%= link_to 'Destroy Comment', [comment.article, comment],
method: :delete,
data: { confirm: 'Are you sure?' } %>
</p>
Clicking this new "Destroy Comment" link will fire off a DELETE
/articles/:article_id/comments/:id to our CommentsController, which can then use this to find the
comment we want to delete, so let's add a destroy action to our controller
(app/controllers/comments_controller.rb):
def destroy
@article = Article.find(params[:article_id])
@comment = @article.comments.find(params[:id])
@comment.destroy
redirect_to article_path(@article)
end
private
def comment_params
params.require(:comment).permit(:commenter, :body)
end
end
The destroy action will find the article we are looking at, locate the comment within the
@article.comments collection, and then remove it from the database and send us back to the show action
for the article.
9 Security
https://guides.rubyonrails.org/getting_started.html 52/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
If you were to publish your blog online, anyone would be able to add, edit and delete articles or delete
comments.
Rails provides a very simple HTTP authentication system that will work nicely in this situation.
In the ArticlesController we need to have a way to block access to the various actions if the person is
not authenticated. Here we can use the Rails http_basic_authenticate_with method, which allows
access to the requested action if that method allows it.
def index
@articles = Article.all
end
We also want to allow only authenticated users to delete comments, so in the CommentsController
(app/controllers/comments_controller.rb) we write:
def create
@article = Article.find(params[:article_id])
# ...
end
https://guides.rubyonrails.org/getting_started.html 53/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
Now if you try to create a new article, you will be greeted with a basic HTTP Authentication challenge:
Other authentication methods are available for Rails applications. Two popular authentication add-ons for
Rails are the Devise rails engine and the Authlogic gem, along with a number of others.
10 What's Next?
Now that you've seen your first Rails application, you should feel free to update it and experiment on your
own.
Remember you don't have to do everything without help. As you need assistance getting up and running
with Rails, feel free to consult these support resources:
https://guides.rubyonrails.org/getting_started.html 54/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
11 Configuration Gotchas
The easiest way to work with Rails is to store all external data as UTF-8. If you don't, Ruby libraries and
Rails will often be able to convert your native data into UTF-8, but this doesn't always work reliably, so
you're better off ensuring that all external data is UTF-8.
If you have made a mistake in this area, the most common symptom is a black diamond with a question
mark inside appearing in the browser. Another common symptom is characters like "ü" appearing
instead of "ü". Rails takes a number of internal steps to mitigate common causes of these problems that
can be automatically detected and corrected. However, if you have external data that is not stored as UTF-
8, it can occasionally result in these kinds of issues that cannot be automatically detected by Rails and
corrected.
Your text editor: Most text editors (such as TextMate), default to saving files as UTF-8. If your text
editor does not, this can result in special characters that you enter in your templates (such as é)
to appear as a diamond with a question mark inside in the browser. This also applies to your i18n
translation files. Most editors that do not already default to UTF-8 (such as some versions of
Dreamweaver) offer a way to change the default to UTF-8. Do so.
Your database: Rails defaults to converting data from your database into UTF-8 at the boundary.
However, if your database is not using UTF-8 internally, it may not be able to store all characters
that your users enter. For instance, if your database is using Latin-1 internally, and your user
enters a Russian, Hebrew, or Japanese character, the data will be lost forever once it enters the
database. If possible, use UTF-8 as the internal storage of your database.
Feedback
You're encouraged to help improve the quality of this guide.
Please contribute if you see any typos or factual errors. To get started, you can read our documentation
contributions section.
https://guides.rubyonrails.org/getting_started.html 55/56
9/9/2018 Primeros pasos con Rails - Ruby on Rails Guides
You may also find incomplete content or stuff that is not up to date. Please do add any missing
documentation for master. Make sure to check Edge Guides first to verify if the issues are already fixed or
not on the master branch. Check the Ruby on Rails Guides Guidelines for style and conventions.
If for whatever reason you spot something to fix but cannot patch it yourself, please open an issue.
And last but not least, any kind of discussion regarding Ruby on Rails documentation is very welcome on
the rubyonrails-docs mailing list.
Este trabajo es bajo licencia de Creative Commons Reconocimiento-Compartir Igual 4.0 Internacional License
"Rails", "Ruby on Rails" y el logotipo de Rails son marcas registradas de David Heinemeier Hansson. Todos los derechos reservados.
https://guides.rubyonrails.org/getting_started.html 56/56