Skip to content

Instantly share code, notes, and snippets.

config.cache_classes = false
this works, details are updated accordingly
def fees
@pin = Pin.new
@title = "Pay Fees"
if request.post?
pin = Pin.check_pin_value(params[:pin][:number])
user = User.find(current_user.id)
amount = params[:pin][:value]
if pin.nil?
flash.now[:error] = "Unable to Pay Fees,Check You Pin and Make sure it has not been Used"
@iwada
iwada / gist:1211275
Created September 12, 2011 13:41
custom Authentication
I have this issue, i'm new to rails. This is a custom authentication code, but when i enter a email address contained in my database, i get "Invalid Email/password Combination",
If i enter a valid email address but leave the password field blank, the user is loged in,What am i doing wrong please?
User.rb
def has_password?(submitted_password)
encrypted_password == encrypt(submitted_password)
end
class << self
validates_attachment_size :pic, :less_than=>1.kilobyte,
:if => Proc.new { |imports| !imports.pic_file_name.blank? }
validates_attachment_presence :pic
validates_attachment_size :pic, :less_than => 5.megabytes
validates_attachment_content_type :pic, :content_type => ['image/jpeg', 'image/png']
@iwada
iwada / gist:1203250
Created September 8, 2011 12:10
Paperclip
I have this in my Model
validates_attachment_size :pic, :less_than=>15.kilobyte,
:if => Proc.new { |imports| !imports.pic_file_name.blank?
which should presumably rejects uploards larger than 15 Kb, but i can upload files larger than 15KB, it shows no errors
PinController
def fees
@title = "Pay Fees"
if request.post?
pin = Pin.check_pin_value(params[:pin][:number])
if pin.nil?
flash.now[:error] = "Unable to Pay Fees,Check You Pin and Make sure it has not been Used"
else
# pin_value = pin.pin_value
@iwada
iwada / gist:1195848
Created September 5, 2011 20:28
Passing auguments to before_*
class XController < ApplicationController
before_filter :except => [:show, :..] do |c| c.check({".." => "administrator"})
end
# ... various methods ...
end
def check(x)
......
end