Skip to content

Instantly share code, notes, and snippets.

View richardsondx's full-sized avatar

Richardson Dackam richardsondx

View GitHub Profile
@richardsondx
richardsondx / JirasController
Created March 12, 2014 22:04
WebsocketRails
class JirasController < ApplicationController
def action
send_message :event_name, new_message
end
end
app = angular.module("wallrentjs", ["ngResource"])
@ArtworkCtrl = ($scope, $http) ->
$http(
method: "GET"
url: "http://localhost:3000/api/artists/ac9998fc-1735-44fc-8ae0-814154d9cb2f/artworks"
).success(data) ->
console.log(data)
$scope.artworks = data
@richardsondx
richardsondx / country_select.rb
Last active August 29, 2015 13:56
Error with activeadmin and country_select
module ActionView
module Helpers
module FormOptionsHelper
# Return select and option tags for the given object and method, using country_options_for_select to generate the list of option tags.
def country_select(object, method, priority_countries = nil, options = {}, html_options = {})
InstanceTag.new(object, method, self, options.delete(:object)).to_country_select_tag(priority_countries, options, html_options)
end
# Returns a string of option tags for pretty much any country in the world. Supply a country name as +selected+ to
# have it marked as the selected option tag. You can also supply an array of countries as +priority_countries+, so
# that they will be listed above the rest of the (long) list.
# products > _form.html.erb
<%= form_for(@product) do |f| %>
<%= f.fields_for @product, :previews do |e| %>
<%= e.file_field :image, :name => "product[previews_attributes][0][image]" ,:class => "LargeformTextfield interspaceBottom", :placeholder => "ADD IMAGES" %>
<%= e.file_field :image, :name => "product[previews_attributes][1][image]" ,:class => "LargeformTextfield interspaceBottom", :placeholder => "ADD IMAGES" %>
<%= e.file_field :image, :name => "product[previews_attributes][2][image]" ,:class => "LargeformTextfield interspaceBottom", :placeholder => "ADD IMAGES" %>
<%= e.file_field :image, :name => "product[previews_attributes][3][image]" ,:class => "LargeformTextfield interspaceBottom", :placeholder => "ADD IMAGES" %>
<%= e.file_field :image, :name => "product[previews_attributes][4][image]" ,:class => "LargeformTextfield interspaceBottom", :placeholder => "ADD IMAGES" %>
<%= e.file_field :image, :name => "product[previews_attributes]
@richardsondx
richardsondx / Gemfile
Last active December 17, 2015 21:59
FileUpload + Carrierwave + Nested Form + Javascript issue
gem 'rails', '3.2.11'
group :assets do
gem 'angularjs-rails'
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'jquery-fileupload-rails'
gem 'uglifier', '>= 1.0.3'
@richardsondx
richardsondx / application_controller.rb
Last active December 17, 2015 05:19
Authentification won't work in production. It seems that the LDAP server find the user but when devise try to make the redirection something happen and the user is being redirected to the landing page. The flash message I receive on the landing page is "invalid username or password" but the same username and password work perfectly in staging.
class ApplicationController < ActionController::Base
rescue_from DeviseLdapAuthenticatable::LdapException do |exception|
render :text => exception, :status => 500
end
rescue_from Net::LDAP::LdapError do |exception|
render :text => "#{exception}. Try to setup an ssh tunnel to your LDAP server.", :status => 500
end
def redirect_to_ssl
@richardsondx
richardsondx / Project.rb
Created May 7, 2013 21:46
Dynamic form doesn't work with edit view but work fine with "new".
class Project < ActiveRecord::Base
attr_accessible :options, :values_attributes
accepts_nested_attributes_for :values, allow_destroy:true
has_many :values, :class_name => "OptionValue"
def options
options_hash = {}
self.values.each do |v|
class Project < ActiveRecord::Base
# ...
def to_params
"#{project_name}"
end
end
@richardsondx
richardsondx / I tried this
Created January 10, 2013 06:40
trying to turn %button.twitter-button.btn.btn-inverse into an anchor link
= provide(:css_class, "landing")
.row-fluid
.span12
.banner
%section.main
%h1{:class => "depth", :title => "Ruby on Rails Theme Marketplace"}
Ruby on Rails Themes
.sub-header
%h2 Open Marketplace
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?1.29.1"></script>
<style type="text/css">
html, body, #map {
width: 100%;