Commit 6dd000f4 authored by Sara Kuqi's avatar Sara Kuqi
Browse files

deploy with capistrano

parent ac6a7fd1
......@@ -22,3 +22,4 @@
# Ignore config
/config/database.yml
/config/env.yml
......@@ -16,13 +16,14 @@ require 'capistrano/delayed_job'
# https://github.com/capistrano/rails
# https://github.com/capistrano/passenger
#
# require 'capistrano/rvm'
require 'capistrano/rvm'
# require 'capistrano/rbenv'
# require 'capistrano/chruby'
# require 'capistrano/bundler'
# require 'capistrano/rails/assets'
# require 'capistrano/rails/migrations'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
# require 'capistrano/passenger'
# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }
Rake::Task[:production].invoke
......@@ -17,7 +17,7 @@ gem "cocoon"
gem "json"
gem "mail"
gem "delayed_job_active_record"
gem 'capistrano3-delayed-job'
gem 'daemons'
#bootstrap
gem 'bootstrap-sass', '~>3.3.6'
# Use sqlite3 as the database for Active Record
......@@ -62,6 +62,10 @@ group :development do
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
gem "capistrano", "~> 3.6"
gem 'capistrano3-delayed-job'
gem 'capistrano-rvm'
gem 'capistrano-rails'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
......
......@@ -57,7 +57,16 @@ GEM
i18n
rake (>= 10.0.0)
sshkit (>= 1.9.0)
capistrano-bundler (1.2.0)
capistrano (~> 3.1)
sshkit (~> 1.2)
capistrano-harrow (0.5.3)
capistrano-rails (1.2.0)
capistrano (~> 3.1)
capistrano-bundler (~> 1.1)
capistrano-rvm (0.1.2)
capistrano (~> 3.0)
sshkit (~> 1.2)
capistrano3-delayed-job (1.7.2)
capistrano (~> 3.0, >= 3.0.0)
cocoon (1.2.9)
......@@ -69,6 +78,7 @@ GEM
execjs
coffee-script-source (1.10.0)
concurrent-ruby (1.0.2)
daemons (1.2.4)
debug_inspector (0.0.2)
delayed_job (4.1.2)
activesupport (>= 3.0, < 5.1)
......@@ -210,9 +220,12 @@ DEPENDENCIES
bootstrap-will_paginate (~> 0.0.10)
byebug
capistrano (~> 3.6)
capistrano-rails
capistrano-rvm
capistrano3-delayed-job
cocoon
coffee-rails (~> 4.2)
daemons
delayed_job_active_record
font-awesome-rails
jbuilder (~> 2.5)
......
class ResultsController < ApplicationController
before_action :set_result, only: [:show, :edit, :update, :destroy]
before_action :correct_user, only: :destroy
def new
@result = Result.new
......@@ -57,9 +58,13 @@ class ResultsController < ApplicationController
def set_result
@result = Result.find(params[:id])
end
def correct_user
@result = current_user.results.find_by(id: params[:id])
#redirect_to root_url if @result.nil?
end
def result_params
params.require(:result).permit(:sample_id, :measurement, :name)
params.require(:result).permit(:sample_id, :user_id, :measurement, :name)
params.fetch(:result, {})
end
end
class Result < ApplicationRecord
belongs_to :sample
belongs_to :user
#validates :user_id, presence: true
before_save :measurement
def measurement
......
class User < ApplicationRecord
has_many :samples, dependent: :destroy
has_many :microposts, dependent: :destroy
has_many :results, dependent: :destroy
self.inheritance_column = :type
attr_accessor :remember_token, :activation_token, :reset_token
......
......@@ -99,7 +99,7 @@ $(document).ready(function() {
<%sum2=0;i=1 %>
<% @sample.results.each do |result| %>
<tr>
<td>Result <%= i %> : </td>
<td>Result <%= i %> :<%#= @user.name %> </td>
<td><%= result.element_C %> </td>
<%sum2=sum2.to_f+result.element_C.to_f %>
<td><%= result.element_N %> </td>
......
......@@ -2,7 +2,7 @@
lock '3.6.1'
set :application, 'ela2'
set :repo_url, 'git@git.scc.kit.edu/ComPlat/ela2.git'
set :repo_url, 'git@git.scc.kit.edu:ComPlat/ela2.git'
# Default branch is :master
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
......@@ -22,9 +22,14 @@ set :repo_url, 'git@git.scc.kit.edu/ComPlat/ela2.git'
# Default value for :pty is false
# set :pty, true
set :stage, :production
set :branch, 'mailer'
set :deploy_to, '/home/ela/www/ela'
#role :all, %w{deploy@server.com}
server 'itg-complat1-l.itg.kit.edu', user: 'ela', roles: %w{web app db}, my_property: :my_value
fetch(:default_env).merge!(rails_env: :production)
# Default value for :linked_files is []
append :linked_files, 'config/database.yml', 'config/secrets.yml'
append :linked_files, 'config/database.yml', 'config/secrets.yml', 'config/env.yml'
# Default value for linked_dirs is []
append :linked_dirs, 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'public/system'
......
......@@ -7,7 +7,7 @@
# server 'example.com', user: 'deploy', roles: %w{app web}, other_property: :other_value
# server 'db.example.com', user: 'deploy', roles: %w{db}
server 'itg-complat1-l', user: 'ela', roles: %w{app web db}
server 'itg-complat1-l.itg.kit.edu', user: 'ela', roles: %w{app web db}
set :ssh_options, {
forward_agent: false,
......
class AddUserIdToResults < ActiveRecord::Migration[5.0]
def change
add_column :results, :user_id, :integer
end
end
......@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20161125091210) do
ActiveRecord::Schema.define(version: 20161202142141) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
......@@ -49,6 +49,7 @@ ActiveRecord::Schema.define(version: 20161125091210) do
t.string "name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "user_id"
end
create_table "samples", force: :cascade do |t|
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment