I am following this code https://stackoverflow.com/a/17886089/692622, here is my client.rb model file and client_controller.rb file
# app/models/client.rb
before_create :add_unsubscribe_hash
private
def add_unsubscribe_hash
self.unsubscribe_hash = SecureRandom.hex
end
# app/controllers/clients_controller.rb
def unsubscribe
client = Client.find_by_unsubscribe_hash(params[:unsubscribe_hash])
client.update_attribute(:subscription, false)
end
but when I am trying to add clients through /clients/new (I have all the 7 methods in controller file too), I am getting error
undefined local variable or method `add_unsubscribe_hash'
The error is coming while saving client in create method
respond_to do |format|
if @client.save
any idea what is wrong since everything looks alright
EDIT - I have added the model code at pastebin http://pastebin.com/jkegLsaE