For your application, the Ruby on Rails Controller is the logical center. It combines, Communication between model, user, and Views. For ancillary services controller is home.
Know more about Ruby on Rails controller by Ruby On Rails Online Training
And the controller is right over Internal actions and external Requests. And it is having. An option to take care of user-friendly URLs. It can manage classes so that it gives the users a good Impression, of communication with Applications.
1.Ruby on Rails Controller:
The making of a controller is simple and familiar to the Process. Similarly which we have Implemented for a making a model. We will start one simple controller here.
library\> rails generate controller Book
Make sure that you are using one form. And this is Ruby on the Rails process which you should follow every time while you are creating a Controller.
The Below command operates so many tasks. which are related here.
It starts a file called app/controllers/book_controller.rb.
If you see at book_contorller.rb, you will find the below.
Class Book-controller < application controller
Controller classes receive from the Application controller, and that will be another file. Controller folder : Application.rb
The App Controller has performed in all your controllers and it will be received from, Rails Action controller: Basic Session.
And there is no need to worry about the Application controller. So let's understand a few ways shorten in book_controller.rb. Based on your usage, you can form. So many numbers of functions in this file.
No, we will Implement each and every method one by one.
The method list will provide you a book list in the DataBase. You can get this functionality by getting by the below lines of code. You can edit the following lines in the book_controller.rb file.
@books = book.all
@book = Book.all, This line in the list method will tell rails to get search the table books and so that each row is stored in @book. Instance object.
The next one is we have to Implement the show method.
Show Method will show on the Display only a few other details on a single book. This method will be received by very few lines of scripting.
@book = Book.find(param[:id]}
The show functionality @book = Book.find(param[:id]) line will guide rails to search only the book. That which has ID Defined in param [: id]
Param is a container object, that starts. You to pass values in the call method. For Instance, when you are on the page, it is called by a list method. You have an option to click on a link for a particular book. It releases the ID of that Book. By the param object. So that shows we can see a specific book.
4.Making into Process with a New Method:
Generally, in the new method, the Rails will start a new Object. So just add the below code in this method.
The updated method lets rails to know that you can start a new object. So by simply adding the below code in this method.
@book = Book.new
@subjects = subject.all
The above method will be considered. When you show the page to the user to take his Input. The second line shows subjects from Database and keeps in an array of @subjects.
5.Processing the Create Method:
Especially, When you take user Input Format with HTML form. It is the starting point to create. Progress into the Database. To get this, you have to start a method in book_controller to equal the following data at Ruby on Rails.
Finally, these are the best-known facts about, the History of Ruby On Rails Controller, in upcoming blogs we will update more data on this topic.