dimanche 7 août 2016

Passing ID from one controller to another

So I am developing a job portal website, and I am looking to pass the current job ID over to the "job applications" controller #new method, but I am having issues being able to do so.

So when a user clicks the "Job_applications#new", It gets the current page job_id.

Models

Class Job 
  has_many :job_applications
end

Class JobApplication
  belongs_to :job
end

In my Job_Applications Controller

def create
    @job = Job.find(params[:id])
    *Additional save & Redirect methods*
end

In my View I have the following code

<%= link_to "Apply Now",new_job_application_path(:id => @job.id), class: "btn btn-primary" %>

I know I am doing something stupid here, Ideally, I would like to pass the job id without it being in the URL

Example

http://ift.tt/2bbYYw7

However this method shows this

http://ift.tt/2b0Eb2f

Any help greatly appreciated

Aucun commentaire:

Enregistrer un commentaire