0% found this document useful (0 votes)
54 views1 page

Rails Guide for Developers

The document discusses the major principles of Rails including Don't Repeat Yourself (DRY) and Convention Over Configuration. It then explains the Model-View-Controller (MVC) pattern in Rails where the model manages data and logic, the controller receives and routes requests and collects data, and the view displays the data in a human readable format using templates like ERB. It also mentions conventions for naming models and controllers and common Rails helpers like form_with, link_to, and authentication gems like Devise and Authlogic.

Uploaded by

LêThànhViệt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views1 page

Rails Guide for Developers

The document discusses the major principles of Rails including Don't Repeat Yourself (DRY) and Convention Over Configuration. It then explains the Model-View-Controller (MVC) pattern in Rails where the model manages data and logic, the controller receives and routes requests and collects data, and the view displays the data in a human readable format using templates like ERB. It also mentions conventions for naming models and controllers and common Rails helpers like form_with, link_to, and authentication gems like Devise and Authlogic.

Uploaded by

LêThànhViệt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Rails philosophy includes 2 major guiding principles:

- Don’t Repeat Yourself (DRY).


- Convention Over Configuration.
Create a new Rails project
Directory of Rails application
Some command:
rails server | rails s
rails c | rails c --sandbox
rails generate | rails g
rails db:migrate
MVC in Rails
Model: Responsible for representing business data and logic.
“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.”
=> Controller nhận các request cụ thể đến ứng dụng. Routing quyết định controller nào sẽ xử lý
request đó. Thông thường, có nhiều hơn một routing đến mỗi controller, và mỗi route khác nhau sẽ
tương ứng bởi những action khác nhau. Mỗi action thu thập thông tin để cung cấp đến cho view.

“A view's purpose is to display this information in a human readable format. An important


distinction to 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.”
=> View thể hiện thông tin đến cho người dùng. Template được viết bởi ngôn ngữ erb.
<%= %> => print
<% %> => execute
Name convention for model name, controller name
form_with helper to create form in Rails

http_basic_authenticate_with method, which allows access to the requested action if that method
allows it.
link_to method , create hyperlink based on text to display.

Gem Devise and Authlogic are used to authenticate.

You might also like