Skip to content

Instantly share code, notes, and snippets.

Marco Mastrodonato marcomd

Block or report user

Report or block marcomd

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@marcomd
marcomd / gist:3129118
Created Jul 17, 2012
Authenticate your API with devise, token by header
View gist:3129118
#Session controller provides a token
#/controllers/api/sessions_controller.rb
class Api::SessionsController < Devise::SessionsController
before_filter :authenticate_user!, :except => [:create]
before_filter :ensure_params_exist, :except => [:destroy]
respond_to :json
def create
resource = User.find_for_database_authentication(:email => params[:user_login][:email])
return invalid_login_attempt unless resource
View gist:1987631
#yield
class A
def go(*attrs)
p "Before block"
attrs.each do |attr|
p yield(attr)
end if block_given?
p "After block"
end
end
@marcomd
marcomd / gist:1788853
Created Feb 10, 2012
ActiveAdmin: Add attributes_table to generic resource
View gist:1788853
#Add this new method
#activeadmin-0.4.0\lib\active_admin\views\pages\show.rb
#after def attributes_table
def attributes_table_for_resource(specified_resource, *args, &block)
panel(I18n.t('active_admin.details', :model => "#{specified_resource.class.name} #{specified_resource.id}")) do
attributes_table_for specified_resource, *args, &block
end
end
@marcomd
marcomd / devise.it.yml
Created Aug 4, 2011 — forked from jdeyla/devise.it.yml
Suitable for devise 1.4.2
View devise.it.yml
it:
errors:
messages:
expired: "è scaduto ed è necessario richiederne uno nuovo"
not_found: "non trovato"
already_confirmed: "è già stato confermato, riprova a collegarti"
not_locked: "non era bloccato"
not_saved:
one: "un errore ha impedito il salvataggio di %{resource}:"
other: "%{count} errori hanno impedito il salvataggio di %{resource}:"
You can’t perform that action at this time.