Skip to content

Instantly share code, notes, and snippets.

@spacerobotTR
spacerobotTR / _comment.html.erb
Created May 5, 2018 12:22
Rails Ajax Comments
<% @comments.each do |comment| %>
<div class="feed-element">
<div class="media-body" style="font-size:14px;">
<span class="pull-right text-navy"><%= time_ago_in_words(comment.updated_at) %> ago</span>
<strong><%= comment.user.username %></strong> updated this service request.
<br>
<small class="text-muted"><%= @servicerequest.created_at.to_time.strftime('%B %e at %l:%M %p') %></small>
$(function () {
"use strict";
$(function () {
$(".preloader").fadeOut();
});
jQuery(document).on('click', '.mega-dropdown', function (e) {
e.stopPropagation()
});
// ==============================================================
// This is for the top header part and sidebar part
@spacerobotTR
spacerobotTR / application.hbs
Created March 29, 2018 16:28
Files for sidebar
<div id="main-wrapper">
{{#if session.isAuthenticated}}
<header class="topbar">
<nav class="navbar top-navbar navbar-expand-md navbar-light">
<!-- ============================================================== -->
<!-- Logo -->
<!-- ============================================================== -->
<div class="navbar-header">
<div class="row clearfix">
<% if todo_item.completed? %>
<div class="complete">
<%= link_to complete_todo_list_todo_item_path(@todo_list, todo_item.id), method: :patch do %>
<i style="opacity: 0.4;" class="fa fa-check"></i>
<% end %>
</div>
<div class="todo_item">
<p style="opacity: 0.4;"><strike><%= todo_item.content %></strike></p>
</div>
class Project < ApplicationRecord
include AttachmentUploader[:file]
has_one :proj_status, :foreign_key => "status_id", :primary_key => 'status_id'
belongs_to :user
has_many :comments, dependent: :destroy
has_many :uploads, dependent: :destroy
scope :newproj, lambda { where(:status_id < 1)}
validates_presence_of :projname, {:message => "Project Name cannot be blank."}
@spacerobotTR
spacerobotTR / _error_messages.html.erb
Created July 11, 2017 16:43
Project management comments
<% if object.errors.any? %>
<div class="panel panel-danger">
<div class="panel-heading" id="error_explanation">
<h2><%= pluralize(object.errors.count, "error") %>
prohibited this project from being saved:</h2>
<ul>
<% object.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>