[RUBY] What is params

Ruby 2.6.5 Rails 6.0.3.2

When I was studying about Ruby on Rails, it took me a long time to understand params, so I posted it for my own confirmation.

What is params

In a word, it is a "box containing information". For example, we always send a "box containing information" when changing pages. Rather, it is possible to transition pages by sending a "box containing information". I think it is difficult to understand by explaining only in words, so I will explain based on a concrete example.

Specific example

routes.rb


Rails.application.routes.draw do
  resources :hoges, only: [:index, :new]
end

ruby:index.html.erb


  <%= link_to "Open new page", new_hoge_path %>

ruby:new.html.erb


This is a new page.

hoges_controller.rb


class HogesController < ApplicationController
  def index
  end

  def new
  end
end

Suppose you are currently on the index.html.erb page. Then, when I click "Open new page", the following information is sent, the new action of the hoges controller works, new.html.erb opens, and "This is a new page." Is displayed.

{"authenticity_token" => "+ wXNK4Z3C0wrq4AfslPS5zl / 2LSUE6BvV + 23hQpkHryrsVzPb0siDIkarIsNYLK2R502fuXlqQ ==", "commit" => "Open new page", "controller" => "hoges", "action" =

This ** sent information is called params **. Since params is a collection of some information, it is called a "box containing information".

If you take a closer look at params, you can see "controller" => "hoges" and "action" => "new". This allows you to open new.html.erb because it specifies which action on which controller will work.

Please refer to other articles as it will be long if you describe how to check params.

Recommended Posts

What is params
What is Cubby
What is Docker?
What is null? ]
What is java
What is Keycloak
What is maven?
What is Docker
What is self
What is Jenkins
What is ArgumentMatcher?
What is IM-Juggling?
What is SLF4J?
What is Facade? ??
What is Java <>?
What is Gradle?
What is POJO
What is Java
What is centOS
What is RubyGem?
What is programming?
What is before_action?
What is Docker
What is Byte?
What is Tomcat
What is Maven Assembly?
What is `docker-compose up`?
What is a constructor?
What is vue cli
What is an interface?
What is Ruby's self?
What is hard coding?
What is a stream
What is Ruby's attr_accessor?
What is Java Encapsulation?
What is permission denied?
What is instance control?
What is an initializer?
What is an operator?
What is object orientation?
What is Guava's @VisibleForTesting?
What is MVC model?
What is an annotation?
What is Java technology?
What is Java API-java
What is @ (instance variable)?
What is Gradle's Artifact?
What is JPA Auditing?
[Rails] What are params?
[Swift] What is dismiss?
[Java] What is flatMap?
What is a Servlet?
What is web development?
[Java] What is JavaBeans?
[Android] What is Context? ??
[Java] What is ArrayList?
[Ruby] What is true?
What is object-oriented after all?
What is HttpSession session = request.getSession ();
What is docker run -it?
What is Java Assertion? Summary.