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
download & install command line tools for xcode | |
ln -s gcc gcc-4.2 | |
http://stackoverflow.com/questions/6119153/why-do-i-get-a-bcrypt-ruby-gem-install-error |
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 Device < ActiveRecord::Base | |
has_many :device_groupings, :dependent => :destroy | |
has_many :device_groups, :through => :device_groupings | |
end | |
class DeviceGroup < ActiveRecord::Base | |
has_many :device_groupings, :dependent => :destroy | |
has_many :devices, :through => :device_groupings | |
attr_accessible :name, :device_ids # ... |
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 DeviceGroupsController < ApplicationController | |
# ... | |
private | |
def device_group_params | |
params.require(:device_group).permit(:title, {:group_ids => []} ) | |
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
= simple_form_for @portfolio do |f| | |
= f.input :title, label: 'Portfolio Title' | |
= f.simple_fields_for :assets do |assets_form| | |
.duplicatable_nested_form | |
= assets_form.association :stock | |
= assets_form.input :amount, :input_html => { min: 0 } | |
= link_to 'Remove', '', :class => 'destroy_duplicate_nested_form' | |
= assets_form.input :id, as: :hidden |
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
<% if current_page?(controller: 'foo_bar') %> | |
<%= stylesheet_link_tag "foo", media: "all" %> | |
<%= javascript_include_tag "bar" %> | |
<% 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
# ---- edit data below ------------ | |
LDAP_HOST = 'promdmnet.cloudapp.net' | |
LDAP_PORT = 636 # 636 or 389 | |
LDAP_BASE = "dc=promdm, dc=net" | |
LDAP_BIND_USER = "[email protected]" # format is username@domain | |
LDAP_BIND_PASS = "ldapbindpassword" | |
samaccountname = "zm" | |
password = "userpassword" | |
# ----- edit 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
class MyModel < ActiveRecord::Base | |
after_save :do_something, if: :my_filed_changed? | |
def do_something | |
# my_filed has been changed ... do something | |
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
class Collection < ActiveRecord::Base | |
has_many :products | |
scope :live, where("collections.end_date IS NOT NULL AND collections.end_date >= ?", Time.now.to_date) | |
end | |
class Product < ActiveRecord::Base | |
belongs_to :collection | |
# how to DRY this .where ? | |
scope :launched, joins(:collection).where("collections.end_date IS NOT NULL AND collections.end_date >= ?", Time.now.to_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
<div class="card"> | |
<%= image_tag (collection.designer.cover_image_url), class: "center-block" %> | |
<div class="card-hover"> | |
<span class="card-overlay"> | |
<%= collection.designer.fullname %><br> | |
<%= collection.designer.live_collection.name %><br> | |
<%= collection.designer.location %> | |
</span> | |
</div> | |
</div> |
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
# encoding: utf-8 | |
class AviaryUploader < CarrierWave::Uploader::Base | |
# Include RMagick or MiniMagick support: | |
# include CarrierWave::RMagick | |
# include CarrierWave::MiniMagick | |
# Choose what kind of storage to use for this uploader: | |
# storage :file |
OlderNewer