Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8807915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:29:11+00:00 2026-06-14T02:29:11+00:00

This functionality used to work but has suddenly stopped and I have no idea

  • 0

This functionality used to work but has suddenly stopped and I have no idea why. I’ve made changes before I ran the tests but, having retraced my steps I don’t know what has changed. Can a fresh pair of eyes tell me why this is saving the posts but not the locations?

Model Post.rb

class Post < ActiveRecord::Base
 attr_accessible :title, :body, :tag_list, :locations_attributes
 has_and_belongs_to_many :locations
 accepts_nested_attributes_for :locations, :reject_if => :all_blank
end

*Controller Posts_controller.rb *

class PostsController < ::Blogit::ApplicationController

...     

def new
  @post = current_blogger.blog_posts.new(params[:post])
  @location = @post.locations.build
end

def update
  @post = current_blogger.blog_posts.find(params[:id])
  if @post.update_attributes(params[:post])
    redirect_to @post, notice: 'Blog post was successfully updated.'
  else
    render action: "edit"
  end
end

def create
  @post = current_blogger.blog_posts.new(params[:post])
  if @post.save
    redirect_to @post, notice: 'Blog post was successfully created.'
  else
    render action: "new"
  end
end

end

*View _form.html.erb*

<%= nested_form_for(@post, :html=> {:multipart => true, :class=> "new_blog_post", :id=> "new_blog_post"}) do |f| %>

 ...

<%= field do %>
  <%= f.text_field :title, placeholder: "Give your post a title", :class=>"span12" %>
<% end %>
<%= field do %>
  <%= f.text_area :body, placeholder: "Write something here...", :id=>"blog-text", :class=>"span12" %>
 <% end %>

<%= field id: "new_blog_post_tag_field" do %>
  <%= f.label :tag_list, "Tags" %>
  <%= f.text_field :tag_list, placeholder: "tag one, tag two, etc..." %>
<% end %>

<%= f.label :search_locations, "Add locations to your post" %>
   <%= render :partial => 'search_locations', :locals => { :f => f }  %>

 <p><%= f.link_to_add "Add a location", :locations %></p>

<%= actions do %>
<%= f.submit "Submit", :class=>"btn", :disable_with => 'Uploading Image...' %> or 
<%= link_to("cancel", @post.new_record? ? root_path : post_path(@post)) %>

<% end %>

<% end %>

*Form Partial _search_locations.html.erb*

 <%= f.fields_for :locations do |m| %>


 <%= m.text_field :name,:class=>"localename", :id=>"appendedInput", :placeholder=> "Name of the location", :autocomplete => "off" %>


 <span class="add-on"><%= m.link_to_remove do %><i class='icon-trash'></i></span><%end%>


 <% end %>

And the actual submission in the logs comes up as this:

Started PUT "/blog/posts/51-hong-kong" for 127.0.0.1 at 2012-11-06 17:41:00 +0000
Processing by Blogit::PostsController#update as HTML
Parameters: {"utf8"=>"✓", 
"authenticity_token"=>"s+2117Qi/HzO/D/ORINhqHChMJR3S5XK7y/s3rq3dnc=", "post"=>{"title"=>"Hong 
Kong ", "body"=>"Lorem ipsum dolor sit amet, consectetur adipiscing elit. In orci elit,  
rhoncus quis interdum vel, interdum non nulla. Phasellus nec massa lorem. Duis malesuada   
pellentesque orci, accumsan mollis augue aliquam mollis. Pellentesque luctus orci in enim 
hendrerit adipiscing. Mauris tempor tortor in leo posuere tristique.", "tag_list"=>"", 
"locations_attributes"=>{"0"=>{"_destroy"=>"false",    
"name"=>"London","longitude"=>"-0.1276831", "latitude"=>"51.5073346"}}},
"_wysihtml5_mode"=>"1", "name"=>"London", "legname"=>"London", "longitude"=>"-0.1276831",
"latitude"=>"51.5073346", "commit"=>"Submit", "id"=>"51-hong-kong"}

Why is this saving the post but not the locations info?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T02:29:12+00:00Added an answer on June 14, 2026 at 2:29 am

    Solved it, it was a stray bit of code in the model.

    Thanks for all your help!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My work is on MVC3 with Razor, So this is the Scenario I have
How to use this functionality in ninject 2.0? MyType obj = kernel.Get<MyType>(With.Parameters.ConstructorArgument(foo,bar)); The With
Do any libraries exist with this functionality? Any recommendations would be useful. Thanks.
I would like to achieve this functionality. <p:column> <p:commandLink value=prihlasit oncomplete=dlg.show(); action=#{signForProjectBean.setProjectForDetail(item)} /> </p:column>
I would like to ask is there any way to achieve this functionality: I
I 've researched and noticed that ActiveResource lack this functionality. So, what is the
Which method is very effective and simple to code to attain this functionality ?
We alert user using this javascript, now i want to add this functionality to
From: http://developers.soundcloud.com/docs/api/tracks#filtering I'm not sure from the docs if this functionality is available. I
I am implementing this hoemwork functionality using Ocaml: Not allowed to use List module

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.