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
odin git:(master) git remote show origin | |
* remote origin | |
Fetch URL: git@private:odin | |
Push URL: git@private:odin | |
HEAD branch: master | |
Remote branches: | |
HEAD tracked | |
feature-2023-multi-download tracked | |
feature-2062 tracked | |
feature-2064 tracked |
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
= semantic_form_for @article, html: { class: 'form-horizontal' } do |f| | |
= f.inputs do | |
= f.input :name | |
= f.input :customer unless params.include?(:customer_id) | |
= f.input :number | |
= f.input :unit_price, as: :currency | |
= f.input :comments | |
= f.actions do | |
= f.action :submit, button_html: { class: 'btn btn-primary' } |
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
irb(main):019:0> Dir.mkdir "/var/www/vhosts/menuezorderstest.nl/rails/shared/upload/Orders/760/Links" | |
=> 0 |
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
require 'singleton' | |
class PhoneLogger | |
include Singleton | |
def self.set_file(logfile) | |
PhoneLogger.instance.set_file(logfile) | |
end | |
def set_file(logfile) |
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
validates :name, :presence: true, unless: :password_or_email_changed? | |
private | |
def password_or_email_changed? | |
password_changed? || email_changed? | |
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
$.fn.observe = function(time, callback) { | |
return this.each(function() { | |
var form = $(this) | |
var serialized = form.serialize(); | |
setInterval(function() { | |
if (serialized != form.serialize()) { | |
serialized = form.serialize(); | |
callback.call(form); | |
} |
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
Save filter_scope.rb in your lib/ and make sure you lib/ is in your autoload path (I beleive that's default). Then add the following statement in your model: | |
include FilterScope | |
Now you're able to use .filter on your model: | |
Booking.filter(params[:search], [:name, :company, :site]) |
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
scope :between, lambda { |start_date, end_date| | |
joins(sanitize_sql_array(["INNER JOIN clocks clocks_between ON clocks_between.shift_id = shifts.id AND clocks_between.datetime BETWEEN (? AND ?)", start_date, end_date])) | |
} |
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
<tbody> | |
<% products.each do |product| %> | |
<tr> | |
<td><%= link_to product.name, product %></td> | |
<td><%= truncate(strip_tags(product.description), :length => 80) %></td> | |
<td><%= product.price %></td> | |
</tr> | |
<% end %> | |
</tbody> |
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
def initialize(user) | |
if !user.nil? && !user.role.nil? | |
# internal employee | |
if user.company_id == 1 | |
can :manage, :all | |
# consumer | |
else | |
user.permissions.each do |permission| | |
if permission.is_internal? |