You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to attribute_fu
Everything works great with this branch, except when I click the
remove link, it deletes the expected dom element, and when I save the
change is not reflected in DB.. the actualy child model is still there
when I reload.
Any ideas?
James Golick
unread,
Jun 9, 2008, 11:06:16 PM6/9/08
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to attrib...@googlegroups.com
sounds like an issue with either removing all the elements from the form, or :discard_if...
could it be either of those?
pimpmaster
unread,
Jun 10, 2008, 3:18:32 PM6/10/08
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to attribute_fu
Hmm, i just switched back to good ol' prototype and this is still
buggin, so it rules out the Jquery issue.
Can you see where I went wrong?
class Person < ActiveRecord::Base
has_many :phones, :as => :phoneable, :attributes =>
true, :discard_if => :blank?, :dependent => :destroy
end
class Phone < ActiveRecord::Base
belongs_to :phoneable, :polymorphic => true
def blank?; number.blank?; end
end
pimpmaster
unread,
Jun 10, 2008, 3:50:23 PM6/10/08
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to attribute_fu
> sounds like an issue with either removing all the elements from the form
Bingo!
If I have two child objects, it will delete the second one no problem.
But if its just one, att_fu wont delete it.
Is this expected behavior?
James Golick
unread,
Jun 10, 2008, 3:51:23 PM6/10/08
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to attrib...@googlegroups.com
ya, you need this line in your controller
params[:parent][:child_attributes] ||= {}
pimpmaster
unread,
Jun 10, 2008, 5:15:42 PM6/10/08
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to attribute_fu
Weird.. google groups wont let me post.. posting again:
I tried this:
[new_action,create,edit,update].each do |action|
action.before :destroy_lone_submodels
end
def destroy_lone_submodels
params[:person][:phone_attributes] ||= {}
end
and got this:
You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]
pimpmaster
unread,
Jun 10, 2008, 5:06:37 PM6/10/08
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to attribute_fu
James Golick
unread,
Jun 10, 2008, 5:43:39 PM6/10/08
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message