Created
November 4, 2017 03:38
-
-
Save cheynewallace/4943c19f56095de62db633a11693710a to your computer and use it in GitHub Desktop.
Rails Cheatsheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
**Routes** | |
resources :books do | |
get 'search', :on => :collection | |
end | |
**Forms** | |
<%= form_with(model: book, local: true) do |form| %> | |
<%= label_tag(:name, "Name:") %> | |
<%= form.text_field :name %> | |
<%= label_tag(:description, "Description:") %> | |
<%= form.text_field :description %> | |
<div class="actions"> | |
<%= form.submit %> | |
</div> | |
<% end %> | |
**Validation** | |
validates :description, :presence => true | |
**Permit Params** | |
def book_params | |
params.fetch(:book, {}).permit(:name, :description) | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment