I'm new to Ruby. Im working on a project and i got stuck at someplace. I have two html pages, company_profile
and job
. This job
page is rendered inside company_profile
page and there is an add job
button which renders this. This is inside company_profile.html.erb
<% @job_count = 0 %>
<script type="text/html" id="new_company_job_div">
<%= render 'job', job: Job.new(company_id: @company.id), f: f %>
</script>
and inside my job.html.erb i've
<% @job_count += 1 %>
<%= @job_count %>
and some other codes too..
My issue: First time when i add a job
, job_count
goes to 1 and from there that job_count
value is not increasing. It is stuck there.
I have also written a code to render the jobs
page if its present in database.. this is that part of code in comapny_profile that loads the existing columns.
<% if @company.jobs.present? %>
<% @company.jobs.each do |job| %>
<%= render 'job', job: job, f: f %>
<% end %>
<% end
%>
That is if there are 2 columns inside jobs table with matching id those 2 will be present in the page as soon as it loads and also with add job
we can add more. In this case if 2 jobs
are in table job_count will be 2 and on pressing add_count count value will be 3 and from there onwards count_value
is not increased. Appending and all are working fine..
pls help