Guest User

Untitled

a guest
Jun 14th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. ## Emp Model
  2. class Emp < Profile
  3.  
  4. has_one :emp_attributes_set
  5.  
  6. has_many :text_buckets
  7. has_many :multimedia_buckets
  8. has_many :news_buckets
  9. has_many :rss_buckets
  10.  
  11. def before_create
  12. emp_attributes_set = EmpAttributesSet.new
  13. end
  14.  
  15. end
  16.  
  17. ## Edit View
  18. <% if @profile.class==Emp %>
  19. <a href="profile-buckets.html"><h5>Buckets</h5></a>
  20. <a href="/emp_attributes_sets/edit/<%= @profile.emp_attributes_set.id %>"><h5>Edit Style</h5></a>
  21. <% end %>
  22.  
  23. ## Profiles Controller
  24. def create
  25. @profile = Profile.new(params[:profile])
  26.  
  27. @profile.type = params[:profile][:type]
  28. @profile.company_address = Address.new(params[:company_address])
  29. @profile.company_contact = Contact.new(params[:company_contact])
  30. @profile.agency_address = Address.new(params[:agency_address])
  31. @profile.agency_contact = Contact.new(params[:agency_contact])
  32. @profile.processing_contact = Contact.new(params[:processing_contact])
  33. @profile.membership_contact1 = Contact.new(params[:membership_contact1])
  34. @profile.membership_contact2 = Contact.new(params[:membership_contact2])
  35. @profile.billing_contact = Contact.new(params[:billing_contact])
  36.  
  37. respond_to do |format|
  38. if @profile.save
  39. flash[:notice] = 'Profile was successfully created.'
  40. format.html { redirect_to(:action => "index") }
  41. format.xml { render :xml => @profile, :status => :created, :location => @profile }
  42. else
  43. format.html { render :action => "new" }
  44. format.xml { render :xml => @profile.errors, :status => :unprocessable_entity }
  45. end
  46. end
  47. end
  48.  
  49. ## Error
  50. Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id
  51.  
  52. Extracted source (around line #10):
  53.  
  54. 7: <%= debug @profile.class==Emp %>
  55. 8: <% if @profile.class==Emp %>
  56. 9: <a href="profile-buckets.html"><h5>Buckets</h5></a>
  57. 10: <a href="/emp_attributes_sets/edit/<%= @profile.emp_attributes_set.id %>"><h5>Edit Style</h5></a>
  58. 11: <% end %>
  59. 12: <span class="clearfix"></span>
  60. 13: </p>
Add Comment
Please, Sign In to add comment