Skip to content

Instantly share code, notes, and snippets.

Avatar

Sebastjan Hribar sebastjan-hribar

View GitHub Profile
View self_referential_association_hanami.rb
# segment repository
class SegmentRepository < Hanami::Repository
associations do
has_many :translation_records
has_many :segments, through: :translation_records, as: :target_segments
belongs_to :language
end
def find_by_segment_match(source_text_for_lookup, source_lang, target_lang, sim_score, max_results)
View update_files.rb
Views
tmsr/apps/godmode/views/contact_persons/edit.rb
module Godmode
module Views
module ContactPersons
class Edit
include Godmode::View
View tank.rb
require 'ruby2d'
set( { :title => "Project", :background => "navy", :width => 640, :height => 640, } )
class Tank
attr_accessor :x, :y, :width, :height
def initialize
@x = (get :width) / 2
@y = (get :height) / 2
View slot_edit.html.erb
NoMethodError: undefined method `period' for #<Hanami::View::Rendering::Scope:0x007f4c29979510>
/home/seba/.rvm/gems/ruby-2.4.1/gems/hanami-view-1.1.0/lib/hanami/view/rendering/layout_scope.rb:236:in `method_missing'
/home/seba/.rvm/gems/ruby-2.4.1/gems/hanami-view-1.1.0/lib/hanami/view/rendering/scope.rb:81:in `method_missing'
/home/seba/.rvm/gems/ruby-2.4.1/gems/hanami-helpers-1.1.1/lib/hanami/helpers/html_helper/html_builder.rb:383:in `method_missing'
/home/seba/.rvm/gems/ruby-2.4.1/gems/hanami-helpers-1.1.1/lib/hanami/helpers/html_helper/html_builder.rb:383:in `method_missing'
/home/seba/.rvm/gems/ruby-2.4.1/gems/hanami-helpers-1.1.1/lib/hanami/helpers/html_helper/html_builder.rb:383:in `method_missing'
/home/seba/.rvm/gems/ruby-2.4.1/gems/hanami-helpers-1.1.1/lib/hanami/helpers/html_helper/html_builder.rb:383:in `method_missing'
/home/seba/projekti/hanami/egu_1/egu_app/apps/web/templates/slots/edit.html.erb:17:in `block (5 levels) in singleton class'
/home/seba/.rvm/gems/ruby-2.4.1/gems/hanami-helpers-1
@sebastjan-hribar
sebastjan-hribar / edit.html.erb
Created Oct 1, 2017
Hanami 1.0 update action error
View edit.html.erb
<h2>Update guild</h2>
<% unless params.valid? %>
<div class="errors">
<h3>Input error</h3>
<ul>
<% params.error_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
View logger.rb
module Web
module Logging
def self.included(action)
action.class_eval do
unless ENV['HANAMI_ENV'] == "test"
before :write_to_log
end
end
end
View https_nginx
server {
listen 80;
server_name domain_name.com;
return 301 https://$server_name$request_uri;
}
server {
@sebastjan-hribar
sebastjan-hribar / rake_error.rb
Created Jun 9, 2016
helpers rake test error
View rake_error.rb
(eval):2: warning: method redefined; discarding old link
(eval):2: warning: previous definition of link was here
/home/sebastjan/.rvm/gems/ruby-2.2.1/bundler/gems/view-6a51e5cd3daf/lib/hanami/presenter.rb:1: warning: loading in progress, circular require considered harmful - /home/sebastjan/.rvm/gems/ruby-2.2.1/bundler/gems/view-6a51e5cd3daf/lib/hanami/view/escape.rb
from /home/sebastjan/.rvm/gems/ruby-2.2.1/gems/rake-11.1.2/lib/rake/rake_test_loader.rb:4:in `<main>'
from /home/sebastjan/.rvm/gems/ruby-2.2.1/gems/rake-11.1.2/lib/rake/rake_test_loader.rb:4:in `select'
from /home/sebastjan/.rvm/gems/ruby-2.2.1/gems/rake-11.1.2/lib/rake/rake_test_loader.rb:9:in `block in <main>'
from /home/sebastjan/.rvm/gems/ruby-2.2.1/gems/rake-11.1.2/lib/rake/rake_test_loader.rb:9:in `each'
from /home/sebastjan/.rvm/gems/ruby-2.2.1/gems/rake-11.1.2/lib/rake/rake_test_loader.rb:10:in `block (2 levels) in <main>'
from /home/sebastjan/.rvm/gems/ruby-2.2.1/gems/rake-11.1.2/lib/rake/rake_test_loader.rb:10:in `require'
@sebastjan-hribar
sebastjan-hribar / create.rb
Created May 9, 2016
foreign_key issues with tests
View create.rb
module Web::Controllers::Conferences
class Create
include Web::Action
before :check_for_admin_role
expose :conference
params do
View action.rb
module Web::Controllers::Posts
class Update
include Web::Action
before :check_for_admin_role
params do
param :post do
param :title, presence: true
param :body, presence: true
You can’t perform that action at this time.