Skip to content

Create Pizza App #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

ASPhillips8
Copy link
Contributor

Display list of pizzerias with link to form to create a new pizzeria. New Pizzeria creation has validations for name uniqueness and address. Pizzerias show page has link to pizza create form. Pizza has validation for name and description. Creation of successful pizza associates with pizzeria and redirects to pizza show page displaying name, description and link to the pizzeria it belongs to. Created list of pizza with link to pizza show page on each of the pizzeria show page.
Screenshot 2024-08-21 at 11 38 19 AM
Screenshot 2024-08-21 at 11 38 30 AM

Copy link
Contributor

@stephenmckeon stephenmckeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, just a few small things, but lookin good otherwise!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to avoid pushing up changes like this for the real deal. Only commit changes that you actually care about. This means actually taking the time to check what you're staging and committing.

@pizza = Pizza.new(pizza_params)
@pizzeria = @pizza.pizzeria
if @pizza.save
redirect_to pizzeria_pizza_path(@pizzeria, @pizza), notice: 'Pizza was successfully created.'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're not going to handle the notice, then don't include it. Right now, it doesn't look like that message is ever being displayed.


private
def pizza_params
params.require(:pizza).permit(:name,:description, :pizzeria_id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
params.require(:pizza).permit(:name,:description, :pizzeria_id)
params.require(:pizza).permit(:name, :description, :pizzeria_id)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WATCH YOUR SPACING!!!!!!

Comment on lines +1 to +25
<h2>Tell us about this pizza you had at <%= @pizzeria.name %></h2>

<% if @pizza.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@pizza.errors.count, "error") %> prohibited this pizza from being saved:</h2>
<ul>
<% @pizza.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>

<%= form_with model:[@pizzeria, @pizza], local: true do |form| %>
<%= form.hidden_field :pizzeria_id, value: @pizzeria.id %>
<%= form.label :name %>
<%= form.text_field :name %>

<%= form.label :description %>
<%= form.text_area :description %>

<%= form.submit "Create Pizza" %>

<% end %>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<h2>Tell us about this pizza you had at <%= @pizzeria.name %></h2>
<% if @pizza.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@pizza.errors.count, "error") %> prohibited this pizza from being saved:</h2>
<ul>
<% @pizza.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<%= form_with model:[@pizzeria, @pizza], local: true do |form| %>
<%= form.hidden_field :pizzeria_id, value: @pizzeria.id %>
<%= form.label :name %>
<%= form.text_field :name %>
<%= form.label :description %>
<%= form.text_area :description %>
<%= form.submit "Create Pizza" %>
<% end %>
<h2>Tell us about this pizza you had at <%= @pizzeria.name %></h2>
<% if @pizza.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@pizza.errors.count, "error") %> prohibited this pizza from being saved:</h2>
<ul>
<% @pizza.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<%= form_with model:[@pizzeria, @pizza], local: true do |form| %>
<%= form.hidden_field :pizzeria_id, value: @pizzeria.id %>
<%= form.label :name %>
<%= form.text_field :name %>
<%= form.label :description %>
<%= form.text_area :description %>
<%= form.submit "Create Pizza" %>
<% end %>

Comment on lines +3 to +14


<p>
<%= link_to "Tell us about a great Pizza you had at #{@pizzeria.name}", new_pizzeria_pizza_path(@pizzeria) %>
</p>

<h3>Great eats from <%= @pizzeria.name %>:</h3>

<% @pizzeria.pizzas.each do |pizza| %>
<p> <%= link_to pizza.name, pizzeria_pizza_path(pizza)%></p>
<% end %>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<p>
<%= link_to "Tell us about a great Pizza you had at #{@pizzeria.name}", new_pizzeria_pizza_path(@pizzeria) %>
</p>
<h3>Great eats from <%= @pizzeria.name %>:</h3>
<% @pizzeria.pizzas.each do |pizza| %>
<p> <%= link_to pizza.name, pizzeria_pizza_path(pizza)%></p>
<% end %>
<p>
<%= link_to "Tell us about a great Pizza you had at #{@pizzeria.name}", new_pizzeria_pizza_path(@pizzeria) %>
</p>
<h3>Great eats from <%= @pizzeria.name %>:</h3>
<% @pizzeria.pizzas.each do |pizza| %>
<p> <%= link_to pizza.name, pizzeria_pizza_path(pizza)%></p>
<% end %>

Comment on lines +3 to +10
create_table :pizzas do |t|
t.string :name
t.text :description

t.references :pizzeria

t.timestamps
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
create_table :pizzas do |t|
t.string :name
t.text :description
t.references :pizzeria
t.timestamps
end
create_table :pizzas do |t|
t.string :name
t.text :description
t.references :pizzeria
t.timestamps
end

Comment on lines +2 to +5
resources :pizzerias, only: [:new, :create, :show, :index] do
resources :pizzas, only: [:new, :create, :show]
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice change, but watch the SPACING!

Suggested change
resources :pizzerias, only: [:new, :create, :show, :index] do
resources :pizzas, only: [:new, :create, :show]
end
resources :pizzerias, only: [:new, :create, :show, :index] do
resources :pizzas, only: [:new, :create, :show]
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants