Be careful when writing Rails Projects
1. If the form contains data to be sent back to the server, you can use the hidden property control:
Form_for (xxx) do | f |
F. hidden_field: xxx, value: xxx
End
2. If you need some information in the global page framework, but the information belongs to some specific pages, you can use the following method:
<% Content_for: QuestionsCount do %>
<% = @ Question. length if @ question %>
<% = 0 unless @ question %>
<% End %>
Add the following code to pipeline. erb:
<Title> Exams (questions in the question bank <% = yield: QuestionsCount %>) </title>
3. in some redirection or render operations, we may not need to display the page to be redirected in the default page framework. We hope to use a special page framework; in this case, you can manually specify a page framework:
Respond_to do | format |
Format.html {render layout: "my_layout "}
End
4. in some cases, we hope that the email field in the mode can be null or be in a certain format. If validates_format_of is used for verification, we will find that verification fails if its value is null, in addition to the Verification Method with higher degrees of freedom, there is also a simple way to set the allow_blank parameter of validates_format_of to true:
Validates_format_of: email ,\
With:/\ A [^ @] [\ w. -] + @ [\ w. -] + [.] [a-z] {2, 4} \ z/I, allow_blank: true, message: "Incorrect email format"
Install Apache server in Ubuntu and use the Passenger plug-in to deploy Rails Applications
Build a Ruby On Rails platform using CentOS
Build Ruby On Rails in Ubuntu
Web development agile way application Rails agile Web development (original book version 4th). (US) Sam Ruby). [PDF] + source code
For details about Rails, click here
Rails: click here
This article permanently updates the link address: