This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Missing template layouts/application with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}. Searched in: * "/Users/mike.campbell/projects/engines/myengine_shell/app/views" * "/Users/mike.campbell/projects/engines/myengine/app/views" | |
# Myengine is the engine, and MyengineShell is an app which mounts it. | |
# When I create the engine it generates an application.html.erb layout file in app/views/layouts/myengine/application.html.erb. | |
# How come my app can't find the layout? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/decorators/models/my_engine/user_decorator.rb | |
MyEngine::User.class_eval do | |
def self.find_by_name str | |
where("CONCAT(#{table_name}.firstname, ' ', #{table_name}.surname) LIKE :s", { s: "%#{str}%" }) | |
end | |
end | |
# rails c | |
MyEngine::User.find_by_name "John" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define([ | |
'jquery', | |
'underscore', | |
'backbone', | |
'views/request', | |
'views/new_request' | |
], function($, _, Backbone, RequestView, NewRequestView){ | |
var AppView = Backbone.View.extend({ | |
el: $("#request-app"), | |
events: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Task < ActiveRecord::Base | |
def self.todays_tasks | |
where(due_date: Date.today.beginning_of_day..Date.today.end_of_day) | |
end | |
def self.tomorrows_tasks | |
where(due_date: Date.tomorrow.beginning_of_day..Date.tomorrow.end_of_day) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UNITS_IN_MS = { | |
0 => 3600000, #hour | |
1 => 60000, #minute | |
2 => 1000 #second | |
} | |
time = "00:00:33.55" | |
ms = time.split(":").each_with_index.map{|d, i| d.to_f*UNITS_IN_MS[i]}.reduce(:+).to_i | |
=> 33550 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Client < ActiveRecord::Base | |
def to_param | |
slug | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unless File.exists?('Gemfile') | |
File.write('Gemfile', <<-GEMFILE) | |
source 'https://rubygems.org' | |
gem 'rails', github: 'rails/rails' | |
gem 'sqlite3' | |
GEMFILE | |
system 'bundle' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unless File.exists?('Gemfile') | |
File.write('Gemfile', <<-GEMFILE) | |
source 'https://rubygems.org' | |
gem 'rails', github: 'rails/rails' | |
gem 'sqlite3' | |
GEMFILE | |
system 'bundle' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body id="brands" data-hook="body"> | |
<ul class="letters"> | |
<% ('A'..'Z').each do |letter| %> | |
<li><%= link_to letter, "#", class: "key-link", data: { letter: letter } %></li> | |
<% end %> | |
</ul> | |
<hr> | |
<% @brands.each do |key, brands| %> | |
<ul class="brand-letters"> | |
<li id="letter-<%= key %>" class="key"><%= key %></li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Plugin1 | |
def some_method | |
puts "ha!" | |
end | |
end | |
module Plugin2 | |
def some_method_again | |
puts "hrn..." | |
end |