Random Gap in Row of 3 Columns - ruby-on-rails

Here is what I mean, as you can see there is a gap in the second row and the missing panel is shuffled down to a fourth row that shouldn't exist. It makes no sense. I'm using Bootstrap 3 if that helps at all. Let me know if you guys need anything else.
Here is my html: app\views\blog_posts\index.html.erb and scss: app\assets\stylesheets\blog_posts.scss
.banner {
font-family: 'Pacifico', cursive;
color: white;
text-shadow: 1px 1px 8px $myw-pink;
font-size: 80px;
text-align: center;
margin: 50px 0 40px 0;
}
.panel, .panel-default {
.panel-blog-post {
.panel-heading {
padding: 0px;
p {
font-family: 'Pacifico', cursive;
font-size: 30px;
text-shadow: 2px 2px 2px black;
text-align: center;
padding: 15px;
position: absolute;
}
img {
width: 100%;
border-radius: 2px 2px 0 0;
// .blog-pic-style {
// &:hover {
// filter: brightness(200%);
// transition: ease 1s;
// }
// }
}
}
}
.panel-body {
img {
border-radius: 100%;
}
}
}
.navbar {
margin-bottom: 40px;
background-color: $myw-pink;
border: none;
.navbar-header {
margin: 0 50px 0 50px;
button {
border-width: 2px;
border-color: white;
&:hover {
background-color: $myw-blue;
transition: ease .25s;
}
&:focus {
background-color: $myw-blue;
}
.icon-bar {
background-color: white;
}
}
.navbar-brand {
color: white;
font-family: 'Patua One', cursive;
&:hover {
color: $myw-blue;
transition: ease .25s;
}
}
}
.collapse, .navbar-collapse {
.nav, .navbar-nav, .navbar-right {
margin: 0 50px 0 50px;
li {
a {
color: white;
font-family: 'Patua One', cursive;
&:hover {
color: $myw-blue;
transition: ease .25s;
}
}
}
}
}
}
.panel-default {
border: none;
font-family: 'Patua One', cursive;
.panel-footer {
background-color: $myw-blue;
}
.panel-heading {
background-color: $myw-blue;
color: white;
a {
color: white;
text-decoration: none;
&:hover {
color: $myw-pink;
transition: ease .25s;
text-shadow: 2px 2px 2px white;
}
}
}
}
.container {
margin: 60px auto 20px auto;
}
.contact {
margin: 20px 0 20px 0;
text-align: center;
.custom-button {
height: 34px;
margin: 0 auto 20px auto;
width: 110px;
border: solid white 3px;
font-family: 'Patua One', cursive;
font-size: 20px;
a {
text-decoration: none;
color: white;
}
&:hover {
background-color: $myw-pink;
transition: ease .25s;
}
}
.social-buttons {
.facebook {
#include social-button($facebook);
}
.twitter {
#include social-button($twitter);
}
.linkedin {
#include social-button($linkedin);
}
}
}
<div class="row">
<% #blog_posts.each do |blog_post| %>
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-blog-post">
<div class="panel-heading">
<p><%= link_to blog_post.title, blog_post %></p>
<!-- <div class="blog-pic-style"> -->
<%= link_to (image_tag blog_post.blog_pic.url), blog_post %>
<!-- </div> -->
</div>
</div>
<div class="panel-body">
by <%= blog_post.user.username %>
<% if blog_post.user.avatar.nil? %>
<%= image_tag blog_post.user.avatar.url, size: 40 %>
<% else %>
<%= image_tag 'user.svg', size: 40 %>
<% end %><br />
<p><i>Created: <%= blog_post.created_at.strftime('%m/%d/%Y at %I:%M%p') %></i></p>
<p><%= blog_post.blog[0..150] %>..<%= link_to "Read More", blog_post %></p>
</div>
<% if signed_in? && (current_user.role == "admin" || current_user.role == "manager") %>
<div class="panel-footer">
<%= link_to 'Edit', edit_blog_post_path(blog_post), class: "btn btn-warning" %>
<%= link_to 'Destroy', blog_post, method: :delete, data: { confirm: 'Are you sure?' }, class: "btn btn-danger" %>
</div>
<% end %>
</div>
</div>
<% end %>
</div>
Thanks in advance for the help!

Related

ruby on rails create loop inside onclick

How can I make a loop inside currentSlide(1) so I want everytime .each work to add currentSlide(1) then currentSlide(2) then currentSlide(3) and so on.
<div class="approach" id="app">
<style>
#media (max-width: 600px){
.btn {
padding: 2px 2px 2px 2px !important; */
}}
#myBtnContainer{
display: flex;
}
/* Create three equal columns that floats next to each other */
.column {
float: left;
display: none;
margin: 5px;
border: 1px solid #ccc;
float: left;
width: 282px;
}
.column:hover{
border: 1px solid #777;
}
/* Clear floats after rows */
.row:after {
content: "";
display: table;
clear: both;
}
/* Content */
.content {
width: 100%;
height: 400px;
overflow: hidden;
/*display: flex;*/
flex-direction: column;
justify-content: center;
align-items: center;
position: relative;
}
.content img{
object-fit: cover;
height: auto;
width: 100%;
position: absolute;
}
/* The "show" class is added to the filtered elements */
.show {
display: block;
}
/* Style the buttons */
.btn {
border: none;
outline: none;
padding: 10px 10px;
background-color: #333333;
cursor: pointer;
color: white;
}
.btn:hover {
background-color: #ddd;
}
.btn.active {
background-color: #666;
color: white;
}
.modal {
display: none;
position: fixed;
z-index: 1;
padding-top: 100px;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: black;
}
/* Modal Content */
.modal-content {
position: relative;
background-color: #fefefe;
margin: auto;
padding: 0;
width: 90%;
max-width: 500px;
}
/* The Close Button */
.close {
color: white !important;
position: absolute;
top: 170px;
right: 25px;
font-size: 35px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: #999;
text-decoration: none;
cursor: pointer;
}
.mySlides {
display: none;
}
.cursor {
cursor: pointer
}
/* Next & previous buttons */
.prev,
.next {
cursor: pointer;
position: absolute;
top: 50%;
width: auto;
padding: 16px;
margin-top: -50px;
color: white;
font-weight: bold;
font-size: 20px;
transition: 0.6s ease;
border-radius: 0 3px 3px 0;
user-select: none;
-webkit-user-select: none;
}
/* Position the "next button" to the right */
.next {
right: 0;
border-radius: 3px 0 0 3px;
}
/* On hover, add a black background color with a little bit see-through */
.prev:hover,
.next:hover {
background-color: rgba(0, 0, 0, 0.8);
}
/* Number text (1/3 etc) */
.numbertext {
color: #f2f2f2;
font-size: 12px;
padding: 8px 12px;
position: absolute;
top: 0;
}
img {
margin-bottom: -4px;
}
.caption-container {
text-align: center;
background-color: black;
padding: 2px 16px;
color: white;
}
.demo {
opacity: 0.6;
}
.active,
.demo:hover {
opacity: 1;
}
img.hover-shadow {
transition: 0.3s
}
.hover-shadow:hover {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19)
}
.mySlides img{
padding-top: 70px;
background-color: black;
}
div.desc {
padding: 15px;
text-align: center;
}
#media (max-width:600px) {
.close {
color: white !important;
position: absolute;
top: 120px;
right: 25px;
font-size: 45px;
font-weight: bold;
z-index: 1000;
}
.column {
float: left;
display: none;
margin: 5px;
border: 1px solid #ccc;
float: left;
width: 83px;
}
}
#media (max-width: 320px){
.column {
float: left;
display: none;
margin: 5px;
border: 1px solid #ccc;
float: left;
width: 70px;
}
}
#media only screen and (min-width: 812px) {
.column {
float: left;
display: none;
margin: 5px;
border: 1px solid #ccc;
float: left;
width: 90px;
} }
</style>
<body>
<!-- MAIN (Center website) -->
<div class="container">
<h1>GALLERY</h1>
<div id="myBtnContainer">
<button class="btn" onclick="filterSelection('conversion')"> Conversion</button>
<button class="btn" onclick="filterSelection('fixed-hybrid')"> Fixed Hybrid</button>
<button class="btn" onclick="filterSelection('removal-bar-over-denture')"> Removable Bar Over Denture</button>
<button class="btn" onclick="filterSelection('surgical-guides')"> Surgical Guides</button>
<button class="btn active" onclick="filterSelection('all')"> Show all</button>
</div>
<br>
<!-- Portfolio Gallery Grid -->
<div class="row">
<% #galleries.each do |g| %>
<% [g.image1, g.image2, g.image3, g.image4, g.image5].compact.each_with_index do |image, index| %>
<div class="column <%= g.product_name %>">
<div class="content">
<%= image_tag image.url, style: "width:100%", onclick: "openModal();currentSlide(#{index + 1})" ,class: "hover-shadow cursor"%>
</div>
</div>
<% end %>
<% end %>
<!-- END GRID -->
</div>
<!-- END MAIN -->
</div>
<div id="myModal" class="modal">
<span class="close cursor" onclick="closeModal()">×</span>
<div class="modal-content">
<% #galleries.each do |g| %>
<% [g.image1, g.image2, g.image3, g.image4, g.image5].compact.each_with_index do |image, index| %>
<div class="mySlides">
<div class="numbertext">1 / 4</div>
<%= image_tag image.url, style: "width:100%" %>
</div>
<% end %>
<% end %>
<a class="prev" onclick="plusSlides(-1)">❮</a>
<a class="next" onclick="plusSlides(1)">❯</a>
<div class="caption-container">
<p id="caption">hr</p>
</div>
</div>
<script>
filterSelection("all")
function filterSelection(c) {
var x, i;
x = document.getElementsByClassName("column");
if (c == "all") c = "";
for (i = 0; i < x.length; i++) {
w3RemoveClass(x[i], "show");
if (x[i].className.indexOf(c) > -1) w3AddClass(x[i], "show");
}
}
function w3AddClass(element, name) {
var i, arr1, arr2;
arr1 = element.className.split(" ");
arr2 = name.split(" ");
for (i = 0; i < arr2.length; i++) {
if (arr1.indexOf(arr2[i]) == -1) {element.className += " " + arr2[i];}
}
}
function w3RemoveClass(element, name) {
var i, arr1, arr2;
arr1 = element.className.split(" ");
arr2 = name.split(" ");
for (i = 0; i < arr2.length; i++) {
while (arr1.indexOf(arr2[i]) > -1) {
arr1.splice(arr1.indexOf(arr2[i]), 1);
}
}
element.className = arr1.join(" ");
}
// Add active class to the current button (highlight it)
var btnContainer = document.getElementById("myBtnContainer");
var btns = btnContainer.getElementsByClassName("btn");
for (var i = 0; i < btns.length; i++) {
btns[i].addEventListener("click", function(){
var current = document.getElementsByClassName("active");
current[0].className = current[0].className.replace(" active", "");
this.className += " active";
});
}
</script>
</div>
<script>
function openModal() {
document.getElementById('myModal').style.display = "block";
}
function closeModal() {
document.getElementById('myModal').style.display = "none";
}
var slideIndex = 1;
showSlides(slideIndex);
function plusSlides(n) {
showSlides(slideIndex += n);
}
function currentSlide(n) {
showSlides(slideIndex = n);
}
function showSlides(n) {
var i;
var slides = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("demo");
var captionText = document.getElementById("caption");
if (n > slides.length) {slideIndex = 1}
if (n < 1) {slideIndex = slides.length}
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active", "");
}
slides[slideIndex-1].style.display = "block";
dots[slideIndex-1].className += " active";
captionText.innerHTML = dots[slideIndex-1].alt;
}
</script>
Looks like you just need an index to interpolate into currentSlide.
Start by removing duplication and instead of checking every related image with <% if g.image1.present? %> put them into an array and iterate over it with:
<% [g.image1, g.image2, g.image3].compact.each_with_index do |image, index|
compact will make sure that only present images are there, so you don't have to use if present any more.
And then use onclick: "openModal();currentSlide(#{index + 1})" (as index starts at 0, and you seem to need it to start from 1)
Update:
<% #galleries.each do |g| %>
<% [g.image1, g.image2, g.image3, g.image4, g.image5].compact.each_with_index do |image, index| %>
<div class="column <%= g.product_name %>">
<div class="content">
<%= image_tag image.url,
alt: "conversion",
style: "width:100%",
onclick: "openModal();currentSlide(#{index + 1})",
class: "hover-shadow cursor" %>
</div>
</div>

When I use css on radio buttons it causes the value not to go through when form is submitted

I'm using css on radio buttons for my rails form and when I submit the form the values do not show in my database, but when I take away the css the value does show in the database, so I realize it's something to do with my css, but what is causing it?
form.css
input[type="radio"] {
display: none;
}
label {
display: block;
border: 2px solid #0AA8E5;
border-radius: 20px;
padding: 1rem;
text-align: center;
box-shadow: 0px 3px 10px -2px hsla(150, 5%, 65%, 0.5);
position: relative;
}
input[type="radio"]:checked + label {
background: #0AA8E5;
color: hsla(215, 0%, 100%, 1);
box-shadow: 0px 0px 20px #0AA8E5;
&::after {
color: hsla(215, 5%, 25%, 1);
font-family: FontAwesome;
border: 2px solid hsla(150, 75%, 45%, 1);
content: "\f00c";
font-size: 24px;
position: absolute;
left: 50%;
transform: translateX(-50%);
height: 40px;
width: 50px;
line-height: 50px;
text-align: center;
border-radius: 50%;
background: white;
box-shadow: 0px 2px 5px -2px hsla(0, 0%, 0%, 0.25);
}
}
form.html.erb
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<div class="row">
<div class="col-md-6">
<%= f.radio_button(:role, "startup", id: 'control_01', name: "select", value: 'startup') %>
<label for="control_01">
<h2>Startup</h2>
<p>Join the startup side</p>
</label>
</div>
<div class="col-md-6">
<%= f.radio_button(:role, "investor", id: 'control_02', name: "select", value: 'investor') %>
<label for="control_02">
<h2>Investor</h2>
<p>Join the investor side</p>
</label>
</div>
</div>
<%= f.submit "Sign up", class: "btn btn-success" %>
<% end %>
Just change display: none; to visibility: hidden;
display: none removes the element from the document flow,

gird view not working in rails

I am really new to rails and I'm teaching myself by creating a web app, right now I'm building a pintrest like web app.
Everything is working nicely, but I want the pins to be in a grid sort of view. For that I tried using masonry-rails Gem.
But it doesn't seems to work.
My Index file
<link href="/assets/lposts.css.scss" rel="stylesheet">
<link href="/assets/pins.js.coffee" rel="javascript">
<div class="transitions-enabled" id="pins">
<% #posts.each do |post| %>
<div class="box panel panel-default">
<%= link_to (image_tag post.picture.url), post %>
<h2>
<%= link_to post.title, post %>
</h2>
<p class="user">
Submitted by
UserName
</p>
</div>
<% end %>
</div>
My css file
body {
background: #E9E9E9;
}
h1, h2, h3, h4, h5, h6 {
font-weight: 100;
}
nav {
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.22);
.navbar-brand {
a {
color: #BD1E23;
font-weight: bold;
&:hover {
text-decoration: none;
}
}
}
}
#pins {
margin: 0 auto;
width: 100%;
.box {
margin: 10px;
width: 350px;
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.22);
border-radius: 7px;
text-align: center;
img {
max-width: 100%;
height: auto;
}
h2 {
font-size: 22px;
margin: 0;
padding: 25px 10px;
a {
color: #474747;
}
}
.user {
font-size: 12px;
border-top: 1px solid #EAEAEA;
padding: 15px;
margin: 0;
}
}
}
#edit_page {
.current_image {
img {
display: block;
margin: 20px 0;
}
}
}
#pin_show {
.panel-heading {
padding: 0;
}
.pin_image {
img {
max-width: 100%;
width: 100%;
display: block;
margin: 0 auto;
}
}
.panel-body {
padding: 35px;
h1 {
margin: 0 0 10px 0;
}
.description {
color: #868686;
line-height: 1.75;
margin: 0;
}
}
.panel-footer {
padding: 20px 35px;
p {
margin: 0;
}
.user {
padding-top: 8px;
}
}
}
textarea {
min-height: 250px;
}
My js file
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
$ ->
$('#pins').imagesLoaded ->
$('#pins').masonry
itemSelector: '.box'
isFitWidth: true
In my application.scss
*= require 'masonry/transitions'
In my application.js
//= require masonry/jquery.masonry
The way you include you js assets is wrong.
Please include the js file using
<%= javascript_include_tag 'pins' %>
and place the pins.js.coffee file in precompile assests path
Rails.application.config.assets.precompile += %w(articles.js)
Either you can place your assets in application.js
//= require pins
Hope this is going to work for you.

Vuejs nested post and comment unwanted model binding

In my vuejs code, i am fetching data from a Rails Api, which works fine for the post, i can create a new post but when i want to post a comment and i type in one input field, it types on every other field, i'm a beginner, please help, i don't really know how to phrase a question. Here's the code
<template>
<div class="home">
<div class="panel panel-default panel-shadow">
<div class="panel-body">
<form class="form-group" #submit.prevent="postGossip" style="margin: 10px;">
<textarea class="font-control" v-model="micropost.body" placeholder="What's Happening ?" style="padding: 10px;" rows="5"></textarea>
<span style="color:red">{{ errors.body }}</span>
<button class="btn btn-danger text-right pull-right">Post</button>
</form>
</div>
</div>
<div class="panel panel-white post panel-shadow" v-for="post in microposts" transition="item">
<div class="post-heading">
<div class="pull-left image">
<img src="http://bootdey.com/img/Content/user_1.jpg" class="img-circle avatar" alt="user profile image">
</div>
<div class="pull-left meta">
<div class="title h5">
<b>Anonymous</b>
</div>
<h6 class="text-muted time">{{ getHumanDate(post.created_at) }}</h6>
</div>
</div>
<div class="post-description">
<p>{{post.body}}</p>
<div class="stats">
<div v-on:click="isShow = !isShow" class="text-right">
Comments {{post.comments.length}}
</div>
</div>
</div>
<div class="post-footer" v-show="isShow">
<div class="input-group">
<input class="form-control" placeholder="Add a comment" type="text" v-model="comment.body">
<span class="input-group-addon">
<button class="btn btn-primary" #click="postComment">Post</button>
</span>
</div>
<ul class="comments-list" v-for="comment in post.comments">
<li class="comment">
<a class="pull-left" href="#">
<img class="avatar" src="http://bootdey.com/img/Content/user_1.jpg" alt="avatar">
</a>
<div class="comment-body">
<div class="comment-heading">
<h5 class="time">{{ getHumanDate(comment.created_at) }}</h5>
</div>
<p>{{comment.body}}</p>
</div>
</li>
</ul>
</div>
</div>
</div>
</template>
<script>
import moment from 'moment'
export default {
name: 'home',
data () {
return {
micropost: {
body: ''
},
errors: {},
microposts: [],
comment: {
micropost_id: '',
body: ''
},
isShow: false
}
},
methods: {
postGossip: function () {
let self = this
this.axios.post('http://localhost:3000/api/v1/microposts', {
micropost: self.micropost
}).then(function (response) {
self.errors = {}
self.microposts.unshift(response.data)
self.micropost.body = ''
}).catch(function (response) {
console.log(response)
self.errors = 'response.data.error'
})
},
getPosts: function () {
let self = this
this.axios.get('http://localhost:3000/api/v1/microposts').then(function (response) {
self.microposts = response.data
}).catch(function (errors) {
console.log(errors)
})
},
postComment: function () {
console.log(self.comment)
},
getHumanDate: function (date) {
// return moment(date, 'YYYY-MM-DD').format('DD/MM/YYYY')
return moment(date).fromNow()
}
},
mounted () {
this.getPosts()
}
}
</script>
<style>
body{
background-image: url('../assets/background.png');
}
.panel-shadow {
box-shadow: rgba(0, 0, 0, 0.1) 3px 3px 3px;
}
.panel-white {
border: 1px solid #dddddd;
}
.panel-white .panel-heading {
color: #333;
background-color: #fff;
border-color: #ddd;
}
.panel-white .panel-footer {
background-color: #fff;
border-color: #ddd;
}
.input-group-addon{
background-color: transparent !important;
}
.post .post-heading {
height: 95px;
padding: 20px 15px;
}
.post .post-heading .avatar {
width: 60px;
height: 60px;
display: block;
margin-right: 15px;
}
.post .post-heading .meta .title {
margin-bottom: 0;
}
.post .post-heading .meta .title a {
color: black;
}
.post .post-heading .meta .title a:hover {
color: #aaaaaa;
}
.post .post-heading .meta .time {
margin-top: 8px;
color: #999;
}
.post .post-image .image {
width: 100%;
height: auto;
}
.post .post-description {
margin: 15px;
}
.post .post-description .stats {
margin-top: 20px;
}
.post .post-description .stats .stat-item {
display: inline-block;
margin-right: 15px;
}
.post .post-description .stats .stat-item .icon {
margin-right: 8px;
}
.post .post-footer {
border-top: 1px solid #ddd;
padding: 15px;
}
.post .post-footer .comments-list {
padding: 0;
margin-top: 20px;
list-style-type: none;
}
.post .post-footer .comments-list .comment {
display: block;
width: 100%;
margin: 20px 0;
}
.post .post-footer .comments-list .comment .avatar {
width: 35px;
height: 35px;
}
.post .post-footer .comments-list .comment .comment-heading {
display: block;
width: 100%;
}
.post .post-footer .comments-list .comment .comment-heading .user {
font-size: 14px;
font-weight: bold;
display: inline;
margin-top: 0;
margin-right: 10px;
}
.post .post-footer .comments-list .comment .comment-heading .time {
font-size: 12px;
color: #aaa;
margin-top: 0;
display: inline;
}
.post .post-footer .comments-list .comment .comment-body {
margin-left: 50px;
}
.post .post-footer .comments-list .comment > .comments-list {
margin-left: 50px;
}
.item {
box-sizing: border-box;
background-color: #eee;
border: 1px solid black;
display: inline-block;
width: 100px;
height: 100px;
}
.item-enter {
opacity: 0; /* the state right after enter (enter from this state) */
}
.item-leave {
opacity: 0; /* the state right before leave (leave to this state) */
}
.item-enter-active, .item-leave-active {
transition: opacity .5s ease; /* applied during enter/leave transition */
}
.item-move {
border-color: red;
transition: transform .5s cubic-bezier(.55,0,.1,1); /* applied during moving transition */
}
</style>
And this is what happens:
1
It writes on every comment box insert of just one, any help would be greatly appreciated
This is happening because the object post, that you get from the API returns many comments. Than in your iterator v-for=comment in post.comments you call the iteratee defined in your object locally as comment, what causes a "collision" with the object your defined in your component data.
As post is also a iteratee of microposts you should add the newly created object to microposts. Try the following.
change the iteratee name v-for='comment in post.comments' to c. Of course change the references also in
<div class="comment-body">
<div class="comment-heading">
<h5 class="time">{{ getHumanDate(c.created_at) }}</h5>
</div>
<p>{{c.body}}</p>
</div>
Then your postComment method you can clone the object | clone an object
<button class="btn btn-primary" #click="postComment(post)">Post</button>
Define the method
postComment: function (post) {
post.comments.push({body: this.comment.body});
}
Remember that if a comment has other fields, you need to set them before appending to the parent object post

Ruby on Rails Tutorial - Michael Hartl - Chapter 10 - Header color change

I am following the Ruby on Rails tutorial by Michael Hartl. I am on the chapter 10.
I was following the tutorial. In chapter 10, once when I started the rails server, the color of the background of the bootstrap header was changed from black to light grey. I tried to figure out what happened. I step back on my code. I searched on internet, but I didn't find anything.
I can't be specific when this happened. I am sure that it was on chapter 10.
I didn't make a bundle install, or changed gems, or something similar in the middle.
Here is part of the code
custom.css.scss
#import "bootstrap";
/* mixins, variables, etc. */
$grayMediumLight: #eaeaea;
#mixin box_sizing {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
/* universal */
html {
overflow-y: scroll;
}
body {
padding-top: 60px;
}
section {
overflow: auto;
}
textarea {
resize: vertical;
}
.center {
text-align: center;
h1{
margin-bottom: 10px;
}
}
/* typography */
h1, h2, h3, h4, h5, h6 {
line-height: 1;
}
h1 {
font-size: 3em;
letter-spacing: -2px;
margin-bottom: 30px;
text-align: center;
}
h2 {
font-size: 1.7em;
letter-spacing: -1px;
margin-bottom: 30px;
text-align: center;
font-weight: normal;
color: $grayLight;
}
p {
font-size: 1.1em;
line-height: 1.7em;
}
/* header */
#logo {
float: left;
margin-right: 10px;
font-size: 1.7em;
color: #fff;
text-transform: uppercase;
letter-spacing: -1px;
padding-top: 9px;
font-weight: bold;
line-height: 1;
&:hover {
color: #fff;
text-decoration: none;
}
}
/* footer */
footer {
margin-top: 45px;
padding-top: 5px;
border-top: 1px solid $grayMediumLight;
color: $grayLight;
a {
color: $gray;
&:hover {
color: $grayDarker;
}
}
}
footer small {
float: left;
}
footer ul {
float: right;
list-style: none;
li {
float: left;
margin-left: 10px;
}
}
/* miscellaneous */
.debug_dump {
clear: both;
float: left;
width: 100%;
margin-top: 45px;
#include box_sizing;
}
/* sidebar */
aside {
section {
padding: 10px 0;
border-top: 1px solid $grayLighter;
&:first-child {
border: 0;
padding-top: 0;
}
span {
display: block;
margin-bottom: 3px;
line-height: 1;
}
h1 {
font-size: 1.6em;
text-align: left;
letter-spacing: -1px;
margin-bottom: 3px;
}
}
}
.gravatar {
float: left;
margin-right: 10px;
}
/* forms */
input, textarea, select, .uneditable-input {
border: 1px solid #bbb;
width: 100%;
padding: 10px;
height: auto;
margin-bottom: 15px;
#include box_sizing;
}
#error_explanation {
color: #f00;
ul {
list-style: none;
margin: 0 0 18px 0;
}
}
.field_with_errors {
#extend .control-group;
#extend .error;
}
/* users index */
.users {
list-style: none;
margin: 0;
li {
overflow: auto;
padding: 10px 0;
border-top: 1px solid $grayLighter;
&:last-child {
border-bottom: 1px solid $grayLighter;
}
}
}
.microposts {
list-style: none;
margin: 10px 0 0 0;
li {
padding: 10px 0;
border-top: 1px solid #e8e8e8;
}
}
.content {
display: block;
}
.timestamp {
color: $grayLight;
}
.gravatar {
float: left;
margin-right: 10px;
}
aside {
textarea {
height: 100px;
margin-bottom: 5px;
}
}
_header.html.erb
<header class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<%= link_to "sample app", root_path, id: "logo" %>
<nav>
<ul class="nav pull-right">
<li><%= link_to "Home", root_path %></li>
<li><%= link_to "Help", help_path %></li>
<% if signed_in? %>
<li><%= link_to "Users", users_path %></li>
<li id="fat-menu" class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
Account <b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li><%= link_to "Profile", current_user %></li>
<li><%= link_to "Settings", edit_user_path(current_user) %></li>
<li class="divider"></li>
<li>
<li><%= link_to "Sign out", signout_path, method: "delete" %></li>
</li>
</ul>
</li>
<% else %>
<li><%= link_to "Sign in", signin_path %></li>
<% end %>
</ul>
</nav>
</div>
</div>
</header>
Someone has a similar issue?
Thank you

Resources