Added loads
This commit is contained in:
7
app/views/companies/_company.html.erb
Normal file
7
app/views/companies/_company.html.erb
Normal file
@@ -0,0 +1,7 @@
|
||||
<div id="<%= dom_id company %>">
|
||||
<p>
|
||||
<strong>Name:</strong>
|
||||
<%= company.name %>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
2
app/views/companies/_company.json.jbuilder
Normal file
2
app/views/companies/_company.json.jbuilder
Normal file
@@ -0,0 +1,2 @@
|
||||
json.extract! company, :id, :name, :created_at, :updated_at
|
||||
json.url company_url(company, format: :json)
|
||||
22
app/views/companies/_form.html.erb
Normal file
22
app/views/companies/_form.html.erb
Normal file
@@ -0,0 +1,22 @@
|
||||
<%= form_with(model: company) do |form| %>
|
||||
<% if company.errors.any? %>
|
||||
<div style="color: red">
|
||||
<h2><%= pluralize(company.errors.count, "error") %> prohibited this company from being saved:</h2>
|
||||
|
||||
<ul>
|
||||
<% company.errors.each do |error| %>
|
||||
<li><%= error.full_message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div>
|
||||
<%= form.label :name, style: "display: block" %>
|
||||
<%= form.text_field :name %>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= form.submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
10
app/views/companies/edit.html.erb
Normal file
10
app/views/companies/edit.html.erb
Normal file
@@ -0,0 +1,10 @@
|
||||
<h1>Editing company</h1>
|
||||
|
||||
<%= render "form", company: @company %>
|
||||
|
||||
<br>
|
||||
|
||||
<div>
|
||||
<%= link_to "Show this company", @company %> |
|
||||
<%= link_to "Back to companies", companies_path %>
|
||||
</div>
|
||||
14
app/views/companies/index.html.erb
Normal file
14
app/views/companies/index.html.erb
Normal file
@@ -0,0 +1,14 @@
|
||||
<p style="color: green"><%= notice %></p>
|
||||
|
||||
<h1>Companies</h1>
|
||||
|
||||
<div id="companies">
|
||||
<% @companies.each do |company| %>
|
||||
<%= render company %>
|
||||
<p>
|
||||
<%= link_to "Show this company", company %>
|
||||
</p>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<%= link_to "New company", new_company_path %>
|
||||
1
app/views/companies/index.json.jbuilder
Normal file
1
app/views/companies/index.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.array! @companies, partial: "companies/company", as: :company
|
||||
9
app/views/companies/new.html.erb
Normal file
9
app/views/companies/new.html.erb
Normal file
@@ -0,0 +1,9 @@
|
||||
<h1>New company</h1>
|
||||
|
||||
<%= render "form", company: @company %>
|
||||
|
||||
<br>
|
||||
|
||||
<div>
|
||||
<%= link_to "Back to companies", companies_path %>
|
||||
</div>
|
||||
10
app/views/companies/show.html.erb
Normal file
10
app/views/companies/show.html.erb
Normal file
@@ -0,0 +1,10 @@
|
||||
<p style="color: green"><%= notice %></p>
|
||||
|
||||
<%= render @company %>
|
||||
|
||||
<div>
|
||||
<%= link_to "Edit this company", edit_company_path(@company) %> |
|
||||
<%= link_to "Back to companies", companies_path %>
|
||||
|
||||
<%= button_to "Destroy this company", @company, method: :delete %>
|
||||
</div>
|
||||
1
app/views/companies/show.json.jbuilder
Normal file
1
app/views/companies/show.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.partial! "companies/company", company: @company
|
||||
Reference in New Issue
Block a user