I'm working on getting a pay per click system running on my app, and I've been able to get some help in setting up the framework here on SO. Here's what I've got so far:
class Click < ActiveRecord::Base
belongs_to :deal
belongs_to :vendor
end
class ClicksController < ApplicationController
def create
@deal = Deal.find(params[:deal_id])
@deal.clicks.create
end
end
class Deal < ActiveRecord::Base
belongs_to :vendor
has_many :clicks
end
I want to be able to call my create
method anytime I have a link_to a deal resource. On clicking the user will be taken to that deals view, so I don't want to replace the default method in link_to. Is there a way to call a second method on link_to? Or perhaps using javascript would be a better solution? To be honest, I'm relatively new to RoR, and I don't know much javascript at all. Any suggestions on how best to accomplish this? Thanks in advance!