daily pastebin goal
19%
SHARE
TWEET

Untitled

a guest Feb 22nd, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #for fresh property (with review)
  2.  def new
  3.     @property = Property.new      
  4.     @property.property_reviews.build
  5.  end
  6.    
  7. class Property < ActiveRecord::Base
  8.   has_many :property_reviews, :dependent => :destroy
  9.   accepts_nested_attributes_for :property_reviews
  10. end
  11.    
  12. <%= render :partial => 'form' %>
  13.    
  14. <%= form_for @property, :html => {multipart: true} do |f| %>
  15.     <%= render 'shared/error_messages', object: f.object %>
  16.  
  17.     <%= f.label :address, "Complete Address" %>
  18.     <%= f.text_area :address, rows: 3 %>
  19.  
  20.     <%= f.fields_for :property_reviews do |review| %>
  21.       <%= render "review_fields", r: review %>
  22.     <% end %>
  23.  
  24. <%= f.submit "Submit", class: "btn btn-large btn-primary" %>
  25.    
  26. <p>
  27.    <%= r.label :comments %>
  28.    <%= r.text_area :comments, rows: 5 %>
  29.    ..
  30.    ..
  31. </p>
  32.    
  33. # add another review to existing property
  34.   def add_new_review
  35.     @property = Property.find(params[:id])
  36.     @review = @property.property_reviews.build
  37.   end
  38.    
  39. <b><%= @property.address %></b>
  40. <%= form_for @review do |r| %>
  41.   <%= render "review_fields" %>
  42.  
  43.   <%= f.submit "Submit", class: "btn btn-large btn-primary" %>
  44. <% end %>
  45.    
  46. undefined method `property_reviews_path' for #<#<Class:0xa2ac3a8>:0xa5e487c>
  47.    
  48. <%= form_for @review do |r| %>
  49.    
  50. resources :property_reviews
  51.    
  52. <%= form_for [@property, @review] do |r| %>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top