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
| <ul class='attributes'> | |
| <% @forums.each do |forum| %> | |
| <%= link_to forum.title, forum_path(forum), class: 'btn btn-primary' %> | |
| <% end %> | |
| </ul> |
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 AddTopicsToForums < ActiveRecord::Migration | |
| def change | |
| add_column :forum, :topics, index: true, foreign_key: true | |
| end | |
| 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
| <li><%= link_to "Delete", [@forum, @topic], method: :destroy, | |
| data: { confirm: "Are you sure you want to delete this topic?" }, class: "delete" %></li> |
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
| require 'rails_helper' | |
| RSpec.describe "Users can edit topics" do | |
| let(:author) { FactoryGirl.create(:user) } | |
| let(:forum) { FactoryGirl.create(:forum) } | |
| let(:topic) { FactoryGirl.create(:topic, forum: forum, author: author) } | |
| before do | |
| login_as(author) | |
| visit forum_topic_path(forum, topic) |
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
| module ApplicationHelper | |
| def admins_only(&block) | |
| block.call if current_user.try(:admin?) | |
| end | |
| def author_only(&block) | |
| block.call if current_user == @topic.author.email | |
| end | |
| 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
| module ApplicationHelper | |
| require 'pry' | |
| def admins_only(&block) | |
| block.call if current_user.try(:admin?) | |
| end | |
| def author_only(&block) | |
| binding.pry | |
| block.call if current_user == @topic.author.email |
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='page-header'> | |
| <h1>Welcome to the Forums!</h1> | |
| </div> | |
| <h2>Announcements</h2> | |
| <p> | |
| May 12th, 2016 - The infamous hacker known as Radar has once again infiltrated the website!<br> | |
| Please notify the mods of any suspicous behavior. | |
| </p> |
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
| # The test that is failing | |
| require 'rails_helper' | |
| RSpec.describe "Users can leave comments" do | |
| let(:user) { FactoryGirl.create(:user) } | |
| let(:topic) { FactoryGirl.create(:topic, author: user, forum: forum) } | |
| let(:forum) { FactoryGirl.create(:forum) } | |
| before do |
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 Comment < ActiveRecord::Base | |
| belongs_to :topic | |
| belongs_to :author, class_name: "User" | |
| validates :text, presence: true, length: { minimum: 15 } | |
| end |