Skip to content

Instantly share code, notes, and snippets.

@hieulm
Last active September 14, 2020 20:06
Show Gist options
  • Save hieulm/ce45748e04c615594c834af1a7d16ed1 to your computer and use it in GitHub Desktop.
Save hieulm/ce45748e04c615594c834af1a7d16ed1 to your computer and use it in GitHub Desktop.
Ruby on Rails Documents

Setup working environment

# install rbenv
# install ruby
# install rails
# install debuger
$ gem install ruby-debug-ide debase

Working with source code

$ bundle install # install ruby gems that is defined in gemlock file
$ bundle add ${package_name} # add ruby gem to gemlock file
$ rails s # start ruby on rails project
$ rdebug-ide --port 1234 ./bin/rails s # debug rails project with rdebug-ide
$ ./bin/webpack-dev-server # run webpack dev server to auto compile assets source code

References

<!DOCTYPE html>
<html>
<head>
<title>DxQuesionnaire</title>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/Chart.min.js" crossorigin="anonymous"></script>
</head>
<body>
<%= yield %>
</body>
</html>
<h1>Index Page</h1>
<canvas id="myChart" width="400" height="400"></canvas>
<script>
var ctx = document.getElementById('myChart').getContext('2d');
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'],
datasets: [{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3],
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
'rgba(75, 192, 192, 0.2)',
'rgba(153, 102, 255, 0.2)',
'rgba(255, 159, 64, 0.2)'
],
borderColor: [
'rgba(255, 99, 132, 1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)',
'rgba(153, 102, 255, 1)',
'rgba(255, 159, 64, 1)'
],
borderWidth: 1
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
});
</script>
select
t.name, t.id, r.id as report_id, sum(c.point ) as point_per_theme
from
report_details rd
join choices c on
rd.choice_id = c.id
join questions q on
rd.question_id = q.id
join themes t on
t.id = q.theme_id
join reports r on
rd.report_id = r.id group by t.name, t.id, r.id;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment