adding some parent CRUD
This commit is contained in:
@ -2,7 +2,9 @@
|
||||
|
||||
- @parents.each do |parent|
|
||||
%ul
|
||||
%li #{parent.name} #{page_link(parent)}
|
||||
%li
|
||||
= link_to parent.name, parent_path(parent)
|
||||
= page_link(parent)
|
||||
%li= number_to_phone parent.phone
|
||||
%li= mail_to parent.email
|
||||
%li Children:
|
||||
|
@ -1,6 +1,12 @@
|
||||
%h2 Add a New Parent
|
||||
|
||||
= form_for :parent do |f|
|
||||
- if @parent.errors.full_messages.any?
|
||||
.errors
|
||||
%h1 Uh oh!
|
||||
- @parent.errors.full_messages.each do |e|
|
||||
%p= e
|
||||
|
||||
= form_for @parent, as: :parent, url: add_parent_path do |f|
|
||||
= f.label :first_name
|
||||
= f.text_field :first_name
|
||||
|
||||
@ -14,12 +20,11 @@
|
||||
= f.email_field :email
|
||||
|
||||
%h3 Children:
|
||||
|
||||
= fields_for :child do |child|
|
||||
= child.label :first_name
|
||||
= child.text_field :first_name
|
||||
|
||||
= child.label :last_name
|
||||
= child.text_field :last_name
|
||||
= f.fields_for :children, @parent.children do |c|
|
||||
%fieldset
|
||||
= c.label :first_name
|
||||
= c.text_field :first_name
|
||||
= c.label :last_name
|
||||
= c.text_field :last_name
|
||||
|
||||
= f.submit
|
||||
|
@ -1,2 +1,21 @@
|
||||
%h2 Parent
|
||||
= raw(ap @parent)
|
||||
%h2= @parent.name
|
||||
%p= link_to 'edit', edit_parent_path(@parent)
|
||||
%p Email: #{mail_to(@parent.email, nil, encode: 'hex')}
|
||||
%p Phone: #{number_to_phone @parent.phone} #{page_link(@parent)}
|
||||
|
||||
- unless @parent.children.empty?
|
||||
%p Children:
|
||||
%ul
|
||||
- @parent.children.each do |child|
|
||||
%li
|
||||
= child.name
|
||||
= link_to 'remove', del_parenthood_path(@parent, child), {method: :delete}
|
||||
|
||||
%p Add Child:
|
||||
:ruby
|
||||
select_options = options_from_collection_for_select(@more_children, :id, :name)
|
||||
html_options = {
|
||||
include_blank: false,
|
||||
prompt: 'Add a child to parent'
|
||||
}
|
||||
= select_tag(:child, select_options, html_options)
|
||||
|
Reference in New Issue
Block a user