Skip to content

Instantly share code, notes, and snippets.

View victorhazbunanuff's full-sized avatar

victor hazbun anuff victorhazbunanuff

  • koombea
  • barranquilla
View GitHub Profile
@raecoo
raecoo / before_filter
Created August 27, 2012 03:35
Simple Token Authentication for Devise
# before filter for api controller
def verify_authenticity_token
@current_user = User.find_by_authentication_token(params[:auth_token])
render status: 401, json: { message: '...' } and return unless @current_user
end
@mvilrokx
mvilrokx / jquery-ui-datepicker-rails-part3.html.haml
Created February 27, 2012 19:37
Adding jquery-ui datepicker to rails view with Alternate Field and format
# in your view (HAML + simple_form, simplified for easier reading)
= simple_form_for @bp_reading do |f|
= f.input :recorded_at, :as => :string, :input_html => { :class => 'jquery-ui-date', :value => @bp_reading.try(:recorded_at).try(:strftime,'%m/%d/%Y')}
= f.input :recorded_at, :as => :hidden, :input_html => { :id => 'recorded-at-alt'}
= f.button :submit, :disable_with => "Saving...", :value => "Save"
# in your javascript (coffeescript)
$ ->
$(".jquery-ui-date").datepicker(
altField: "#recorded-at-alt",