ryanb082
8/23/2015 - 7:52 PM

Post not posting to index after view

Post not posting to index after view

<h1>Enter Your Domains Here</h1>

<div class='container'>
 <form class='form-inline'>
  <%= form_for @domain do |f| %>
  <div class='form-group'>
    <%= f.label :domain %>
    <%= f.text_field :domain %>
  </div>
   
  <div class='form-group'>
    <%= f.label :majestic_topic %>
    <%= f.text_field :majestic_topic %>
  </div>
  <div class='form-group'>
    <%= f.label :site_topic %>
    <%= f.text_field :site_topic %>
  </div>
  <div class='form-group'>
    <%= f.label :links %>
    <%= f.number_field :links %>
  </div>
    <%= f.submit 'Submit', class: 'btn btn-primary' %>
  <% end %>

</div>

<div class='container'>
  <table class='table'>
    <caption>Domain Listings</caption>
    <thead>
      <tr>
        <th>#</th>
        <th>Domain</th>
        <th>Majestic Topic</th>
        <th>Site Topic</th>
        <th>Links</th>
      <tr>
    </thead>
    <tbody>
      <%= @domains.each do |domain| %>
        <tr>
          <td><%= domain.domain %></td>
          <td><%= domain.majestic_topic %></td>
          <td><%= domain.site_topic %></td>
          <td><%= domain.links %></td>
        </tr>
      <% end %>
    </tbody>
  </table>  

  <%= link_to 'Create New', new_domain_path, class: 'btn btn-primary' %>
</div>
class DomainsController < ApplicationController

  def index
    @domains = Domain.all
  end

  def create
  @domain = Domain.new(domain_params)
  binding.pry

    if @domain.save
    binding.pry
      flash[:notice] = "Your domain was listed"
      redirect_to root_path
    else
      render :new
    end
  end

  def new
    @domain = Domain.new

    
  end

  def update
  end

  private

  def domain_params
    params.require(:domain).permit(:majestic_topic, :site_topic, :links)
  end

end