I suspect there is a way to get a new view for tag that already belongs to a user, so I can leave the view_permitted set to the user, but I'm not sure what it is.
Mark
def view_permitted?(field)
acting_user== creator
end
Tags do not show up on the edit page. If I put
def view_permitted?(field)
true
end
They do show up, but everyone's tags show up - not just the users own tags. Is there a way to change the permissions so that only the users' own tags show? Or a way to extend the form element tag so that it only shows the current users' tags?
options ||= this_field_reflection.klass.all(:conditions =>this.conditions).select {|x| can_view?(x)}Thanks!
Mark
<form update="recipe">
<check-many:tags/>
<submit label="Update Tags"/>
</form>
And I get the right thing on the page - a list of the user's own tags, with checkboxes. If I click the "Update Tags" button, I get an error.
ActiveRecord::AssociationTypeMismatch (Tag expected, got String):
hobo (1.0.1) lib/active_record/association_proxy.rb:20:in `raise_on_type_mismatch'
hobo (1.0.1) lib/hobo/model.rb:399:in `send'
hobo (1.0.1) lib/hobo/model.rb:399:in `attributes='
hobo (1.0.1) lib/hobo/permissions.rb:194:in `user_update_attributes'
hobo (1.0.1) lib/hobo/permissions.rb:171:in `with_acting_user'
hobo (1.0.1) lib/hobo/permissions.rb:193:in `user_update_attributes'
hobo (1.0.1) lib/hobo/model_controller.rb:593:in `hobo_update'
hobo (1.0.1) lib/hobo/model_controller.rb:156:in `update'
hobo (1.0.1) lib/hobo/controller.rb:23:in `call'
hobo (1.0.1) lib/hobo/controller.rb:23:in `included_in_class'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
By the way, the page itself freezes on the browser window (Safari), and the error page html shows up as text in a modal dialog box - I can't get rid of it and have to quit the browser.
Processing RecipesController#update (for 127.0.0.1 at 2010-11-20 06:41:23) [PUT]
Parameters: {"page_path"=>"recipes/show", "authenticity_token"=>"", "id"=>"3-giant-pickle", "recipe"=>{"tags"=>["", "@3", "@4"]}, "_"=>""}
In the meanwhile I wrote one in erb, like this:
<% form_for @recipe do %>
<% for tag in Tag.find(:all) %>
<% if tag.owner_is? current_user then %>
<%= check_box_tag "recipe[tag_ids][]", tag.id, @recipe.tags.include?(tag) %>
<%= tag.title %>
<% end %>
<% end %>
<%= submit_tag 'Save' %>
<% end %>
It works, and its parameters sent are:
Processing RecipesController#update (for 127.0.0.1 at 2010-11-20 06:41:10) [PUT]
Parameters: {"commit"=>"Save", "authenticity_token"=>"", "id"=>"3-giant-pickle", "recipe"=>{"tag_ids"=>["1", "3", "4"]}}