Merge branch 'cleanup'

This commit is contained in:
Juanjo Bazán
2015-07-18 21:59:41 +02:00
9 changed files with 31 additions and 36 deletions

View File

@@ -1,6 +0,0 @@
class WelcomeController < ApplicationController
def index
end
end

View File

@@ -4,4 +4,8 @@ module ApplicationHelper
debate.tag_list.map { |tag| link_to sanitize(tag), debates_path(tag: tag) }.join(', ').html_safe
end
def percentage(vote, debate)
return if debate.total_votes == 0
debate.send(vote).percent_of(debate.total_votes).to_s + "%"
end
end

View File

@@ -12,12 +12,6 @@ class Debate < ActiveRecord::Base
validates :terms_of_service, acceptance: { allow_nil: false }, on: :create
#vote can be 'likes' or 'dislikes'
def percentage(vote)
return if total_votes == 0
send(vote).percent_of(total_votes)
end
def likes
get_likes.size
end

View File

@@ -1,38 +1,40 @@
<div id="debate-<%= @debate.id %>">
<span id="debate-<%= @debate.id %>" style="width:70%; float:left">
<p><%= @debate.title %></p>
<p><%= @debate.description %></p>
<p>
Creado el: <%= l @debate.created_at.to_date %>
por: <%= @debate.author.name %>
</p>
</div>
</span>
<div>
<span style="width:30%;float:left">
<div id='in_favor'>
<%= link_to "up", debate_votes_path(@debate, value: 'yes'), method: "post" %>
<%= @debate.percentage('likes') %>%
<%= percentage('likes', @debate) %>
</div>
<div id='against'>
<%= link_to "down", debate_votes_path(@debate, value: 'no'), method: "post" %>
<%= @debate.percentage('dislikes') %>%
<%= percentage('dislikes', @debate) %>
</div>
Votos <%= @debate.total_votes %>
</span>
<div style="display: block; width:300px">
<%= render 'shared/tags', debate: @debate %>
</div>
<br/><br/>
<%= render 'shared/tags', debate: @debate %>
<br/><br/>
Deja tu comentario
<%= render 'comments/form', parent: @debate %>
<div id="comments" style="padding-top:20px">
<h2>Comentarios</h2>
<%= render @debate.root_comments %>
</div>
Deja tu comentario
<%= render 'comments/form', parent: @debate %>
<br/><br/>
<%= link_to 'Edit', edit_debate_path(@debate) %> |
<%= link_to 'Back', debates_path %>

View File

@@ -1,9 +1,11 @@
<% if user_signed_in? %>
<li>
<%= link_to('Logout', destroy_user_session_path, method: :delete) %>
</li>
<% else %>
<li>
<%= link_to('Login', new_user_session_path) %>
</li>
<% end %>
<div style="float:right; margin-right:50px">
<% if user_signed_in? %>
<li>
<%= link_to('Logout', destroy_user_session_path, method: :delete) %>
</li>
<% else %>
<li>
<%= link_to('Login', new_user_session_path) %>
</li>
<% end %>
</div>

View File

@@ -11,7 +11,7 @@
<%= javascript_include_tag "application", 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body style="margin-left:50px">
<body style="margin:50px">
<p class="alert"><%= notice %></p>
<p class="alert"><%= alert %></p>

View File

@@ -1 +0,0 @@
<h1>Bienvenido al Ayuntamiento de Madrid</h1>

View File

@@ -5,7 +5,7 @@ Rails.application.routes.draw do
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
root 'welcome#index'
root 'debates#index'
resources :debates do
resources :votes, only: :create
resources :comments, only: :create

View File

@@ -4,7 +4,7 @@ feature "Home" do
scenario "Welcome message" do
visit '/'
expect(page).to have_content 'Bienvenido al Ayuntamiento de Madrid'
expect(page).to have_content 'Debates sobre Madrid'
end
end