-
Notifications
You must be signed in to change notification settings - Fork 6
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
base: master
Are you sure you want to change the base?
Create Pizza App #5
Conversation
git status " "Add boubon gem"
There was a problem hiding this 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!
There was a problem hiding this comment.
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.' |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
params.require(:pizza).permit(:name,:description, :pizzeria_id) | |
params.require(:pizza).permit(:name, :description, :pizzeria_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WATCH YOUR SPACING!!!!!!
<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 %> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<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 %> | |
|
||
|
||
<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 %> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<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 %> | |
create_table :pizzas do |t| | ||
t.string :name | ||
t.text :description | ||
|
||
t.references :pizzeria | ||
|
||
t.timestamps | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
resources :pizzerias, only: [:new, :create, :show, :index] do | ||
resources :pizzas, only: [:new, :create, :show] | ||
end | ||
|
There was a problem hiding this comment.
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!
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 |
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.

