I am a newbie in ruby on rails it's also my first ruby application. The
problem is database relation I am trying to make relation within two
tables and the same procedure are working properly in another relation
but here it's showing an error.
The error is:
'undefined method `create_applied_jobs' for nil:NilClass'
Here are my codes:
applied_job.rb
class AppliedJob < ActiveRecord::Base
belongs_to :jobseekers
end
jobseeker.rb
class Jobseeker < ActiveRecord::Base
has_one :applied_job
end
view_details_controller.rb
def create
params.permit!
if @applied_job =
@current_user.create_applied_jobs(params[:applied_job])
flash[:notice] = "You have applied successfully"
render "viewDetails"
else
render "viewDetails"
flash[:warning] = "Please try agian"
end
end
sessions_helper.rb
def current_user
@current_user ||= Jobseeker.find_by(jobseeker_id:
session[:user_id])
end
viewDetails.html.erb
<%= form_for :applied_job, url: viewDetails_path(@applied_job),
action: :create, method: :post do |f| %>
<ul class="form-style-1">
<li><label>Preferred Joining Date<span
class="required">*</span></label>
<%= f.text_field :preffered_joining_date, class:
'field-long', id: 'datepicker', placeholder: 'Preferred Joining Date'%>
</li>
<li>
<label>Expected Salary <span
class="required">*</span></label>
<%= f.text_field :expected_salary, class: 'form-control',
placeholder: 'Expected Salary'%>
</li>
<li>
<input type="submit" value="Submit" />
</li>
</ul>
<% end %>
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/e886db9469c5390327dc334e520a5aef%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment