bootstrap-editable-rails icon indicating copy to clipboard operation
bootstrap-editable-rails copied to clipboard

Updating nested attributes

Open ingithub opened this issue 12 years ago • 3 comments
trafficstars

Hi,

this gem is working great and nice tutorial how to implement it, but how can I update nested attributes?

Thanks

ingithub avatar Dec 23 '12 11:12 ingithub

How can I access to value? I need assign it to name:

%a{href: '#', class: "editable_#{post.id}", 'data-url' => post_path(post)}= post.name
:javascript
  $(".editable_#{post.id}").editable({
      type: 'text',
      title: 'Enter username',
      params: {
        post: {
          post_translations_attributes:{
            id: "#{post.translation.id}",
            name: 'This value'
          }
        }
      }
  });

ghost avatar Dec 24 '12 12:12 ghost

Thank you for using! I update the repo to enable to overwrite params yesterday. (not released yet)

With a head of the repo, how about this:

gem 'bootstrap-editable-rails', github: 'tkawa/bootstrap-editable-rails'
<% @member.posts.each_with_index do |post, i| %>
  <a href="#" class="post_body" data-type="text" data-resource="member[posts_attributes][<%= i %>]" data-id="<%= post.id %>" data-name="body" data-url="/members/1" data-original-title="Enter body">body</a>
<% end %>
$(".post_body").editable({
  params: function(params) { // for ovewrite params
    params[$(this).data('resource') + '[id]'] = $(this).data('id');
    return params;
  }
});

I'm going to think of a better spec for nested attributes.

tkawa avatar Dec 25 '12 06:12 tkawa

tkawa - I don't understand the status of this issue. Are we supposed to be able to use the above code to fix the issue of editable columns in tables? It doesn't fix it for me.

I used the code above. I now get a popup for every row. I can change the data. But, the record doesn't get changed in the database.

burtondav avatar Jan 11 '13 02:01 burtondav

Hi! Was there ever a feature added that allowed for editing nested attributes? It's working great for everything but my nested attributes. :-/

bytheway875 avatar Oct 15 '13 20:10 bytheway875