##Problems with role-based authorizations
e.g. gem 'access-granted'
https://github.com/chaps-io/access-granted
role :admin, { is_admin: true } do
can :destroy, Post
end
class MyModel < ActiveRecord::Base | |
after_save :do_something, if: :my_filed_changed? | |
def do_something | |
# my_filed has been changed ... do something | |
end | |
end |
<% if current_page?(controller: 'foo_bar') %> | |
<%= stylesheet_link_tag "foo", media: "all" %> | |
<%= javascript_include_tag "bar" %> | |
<% end %> |
= 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 |
class DeviceGroupsController < ApplicationController | |
# ... | |
private | |
def device_group_params | |
params.require(:device_group).permit(:title, {:group_ids => []} ) | |
end | |
# ... |
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 # ... |
require "minitest/mock" | |
require "test_helper" | |
class LoginTest < ActionDispatch::IntegrationTest | |
fixtures :pkis, :organizations, :users | |
def setup | |
@ldap_mock = Minitest::Mock.new | |
@ldap_mock.expect :tap, LdapStub.new | |
end |
<script type="text/javascript"> | |
$(document).on("change", "#my_select", callAjax); | |
$.ajaxSetup({ | |
headers: { 'X-CSRF-Token': '<%= form_authenticity_token.to_s %>' }, | |
timeout: 30000, // timeout after 30 seconds | |
async: true, | |
}); | |
function callAjax() { |
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 |
<%= check_box_tag "foo[delivered]", nil, foo.delivered, data: { id: foo.id }, class: "delivered" %> | |
<script type="text/javascript"> | |
$.ajaxSetup({ | |
headers: { 'X-CSRF-Token': '<%= form_authenticity_token.to_s %>' }, | |
timeout: 30000, // timeout after 30 seconds | |
async: true, | |
cache: false, | |
// dataType: "json", // The type of data that you're expecting back from the server |