Skip to content

Instantly share code, notes, and snippets.

View rvanlieshout's full-sized avatar

Rene van Lieshout rvanlieshout

View GitHub Profile
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
= 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' }
irb(main):019:0> Dir.mkdir "/var/www/vhosts/menuezorderstest.nl/rails/shared/upload/Orders/760/Links"
=> 0
require 'singleton'
class PhoneLogger
include Singleton
def self.set_file(logfile)
PhoneLogger.instance.set_file(logfile)
end
def set_file(logfile)
validates :name, :presence: true, unless: :password_or_email_changed?
private
def password_or_email_changed?
password_changed? || email_changed?
end
$.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);
}
@rvanlieshout
rvanlieshout / description.txt
Created February 21, 2012 10:10
Filter scope
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])
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]))
}
<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>
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?