Last active
December 28, 2015 06:29
-
-
Save travisdmathis/7457525 to your computer and use it in GitHub Desktop.
Blog, w/ Categories using Categorization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <p id="notice"><%= notice %></p> | |
| <p> | |
| <strong>Name:</strong> | |
| <%= @category.name %> | |
| </p> | |
| <%= link_to 'Edit', edit_category_path(@category) %> | | |
| <%= link_to 'Back', categories_path %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Categorization < ActiveRecord::Base | |
| belongs_to :post | |
| belongs_to :category | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Category < ActiveRecord::Base | |
| has_many :categorizations | |
| has_many :posts, :through => :categorizations | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Post < ActiveRecord::Base | |
| has_many :categorizations | |
| has_many :categories, :through => :categorizations | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div class="container"> | |
| <br> | |
| <center> | |
| <div class="well"> | |
| <div class="row"> | |
| <div class="col-md-12"> | |
| <h1 class="text-center"> | |
| Create a New Blog Post | |
| </h1> | |
| <div class="row"> | |
| <div class="col-md-12"> | |
| <%= form_for :post, url: posts_path do |f| %> | |
| <p> | |
| <h4><%= f.label :title %></h4> | |
| <%= f.text_field :title, :size => "100x1" %><br> | |
| </p> | |
| <p> | |
| <h4><%= f.label :body %></h4> | |
| <%= f.text_area :body, :size => "102x10" %><br><br> | |
| </p> | |
| <div class="row"> | |
| <div class="col-md-4"> | |
| <%= f.radio_button("writer", "Anthony") %> | |
| <%= f.label "Anthony Joseph" %><br> | |
| <%= f.radio_button("writer", "Travis") %> | |
| <%= f.label "Travis Mathis" %><br><br> | |
| </div> | |
| <div class="col-md-4"> | |
| <h4 class="center-text"> | |
| <%= link_to 'Add', '/categories' %> Category | |
| </h4> | |
| </div> | |
| <%= select_tag(:categories, options_from_collection_for_select(Category.all, :id, :name),:multiple =>true,:size => 8,:class => "text")%> | |
| <%= f.submit :Submit, class: "btn btn-success btn-lg" %> | |
| <% end %> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment