Note that there are some explanatory texts on larger screens.

plurals
  1. POrails has_one belongs to form submission error
    primarykey
    data
    text
    <p>I have two models and i'm trying to integrate it, i can bring form another model, problem is while submission , id is being updated to null</p> <p>orbituary model:</p> <pre><code>class Orbituarysite &lt; ActiveRecord::Base attr_accessible :birth_place, :death_place, :dob, :dod, :name, :living_place, :orbiturerimage, :salutation, :user_id belongs_to :user mount_uploader :orbiturerimage, OrbiturerUploader has_one :notice_display end </code></pre> <p>Notice model</p> <pre><code>class NoticeDisplay &lt; ActiveRecord::Base attr_accessible :message, :notice_type, :orbituarysite_id, :posted_by, :notice_event_places_attributes, :notice_event_contacts_attributes belongs_to :orbituarysite end </code></pre> <p>orbituary controller:</p> <pre><code>def show @orbituarysite = Orbituarysite.find(params[:id]) if @orbituarysite.notice_display.nil? @notice_display = @orbituarysite.build_notice_display end respond_to do |format| format.html # show.html.erb format.json { render json: @orbituarysite } end </code></pre> <p>end</p> <p>in orbituary sites show view:</p> <pre><code> &lt;% if @orbituarysite.notice_display.nil? %&gt; &lt;%= render 'notice_displays/form' , :remote =&gt; true %&gt; &lt;% end %&gt; </code></pre> <p>while i submit the form i get the following problem, i.e, aftter submission i redirect it to orbituary sites page so i get this in server,</p> <pre><code>Started GET "/orbituarysites/1" for 127.0.0.1 at 2013-09-05 08:58:45 +0530 Processing by OrbituarysitesController#show as HTML Parameters: {"id"=&gt;"1"} User Load (1.6ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1 Orbituarysite Load (1.8ms) SELECT "orbituarysites".* FROM "orbituarysites" WHERE "orbituarysites"."id" = $1 LIMIT 1 [["id", "1"]] NoticeDisplay Load (0.8ms) SELECT "notice_displays".* FROM "notice_displays" WHERE "notice_displays"."orbituarysite_id" = 1 LIMIT 1 History Load (0.9ms) SELECT "histories".* FROM "histories" WHERE "histories"."orbituarysite_id" = 1 LIMIT 1 (0.5ms) BEGIN (0.9ms) UPDATE "histories" SET "orbituarysite_id" = NULL, "updated_at" = '2013-09-05 03:28:46.214455' WHERE "histories"."id" = 2 (25.0ms) COMMIT Rendered histories/_form.html.erb (125.2ms) Rendered memories/_form.html.erb (9.1ms) Rendered condolences/_form.html.erb (14.4ms) Rendered orbiturer_share_images/_form.html.erb (6.2ms) Rendered orbituarysites/show.html.erb within layouts/application (162.6ms) Rendered orbituarysites/_form.html.erb (26.4ms) Completed 200 OK in 944ms (Views: 504.5ms | ActiveRecord: 64.5ms) </code></pre> <p>how to change this because get false in </p> <pre><code> &lt;% if @orbituarysite.notice_display.nil? %&gt; </code></pre> <p>but in console i get true when it is nil and false when there is content</p> <p>Please help me to solve this</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload