How to update and display current user tags marked act_as_taggable_on?

I am not sure how to display tags in my view that belong to a user registered in Omniauth.

The page in the view loads random photos and tags associated with it (through a form that can be updated from this page). It works, but when I log in with Facebook A, it will show exactly the same tags as when logging in with Facebook.

Getting nil firmware with this below. The id for nil is called, which will be 4 by mistake - if you really need the nil identifier, use object_id

View:

<%= render 'tag_form' %> 

Updated: Form:

 <%= form_for @brand, :html => {:multipart => true} do |f| %> <%= f.error_messages %> <p> <%= f.label :tag_list, "Your tags" %> <%= f.text_field :tag_list, :value => @brand.all_tags_list %> </p> <p><%= f.submit "Tag" %></p> <% end %> # <%= f.text_field :tag_list %> was changed to the one above. 

Tags are also called in the user dashboard, as shown below (currently empty, because obviously I can’t update tags right now):

 <%= brand.taggings( :tagger_id => current_user.id, :tagger_type => 'User').collect{|tagging| tagging.tag.to_s}.join(", ") %> 

Application controller displaying current user

 def current_user @current_user ||= User.find(session[:user_id]) if session[:user_id] end 

Brand controller

 helper_method :current_user def index @brands = Brand.all @brand = Brand.order("RANDOM()").first end 

Added: Brand Model

 attr_accessible :name, :tag_list, :current_user acts_as_taggable_on :tags belongs_to :user before_save :set_tag_owner def set_tag_owner set_owner_tag_list_on(@brand, :tags, self.tag_list) self.tag_list = nil end 
0
ruby-on-rails ruby-on-rails-3 tagging omniauth acts-as-taggable-on
source share
2 answers

Just talked to you at IRC, but you can try:

<% = debug @ brand.tag_list%>

in your view. Your user has no tags. If you want tags for your user to add act_as_taggable to the user model


It seems you want to find @brand tags tagged with current_user tag. In this case:

 <%= debug @brand.taggings(:tagger_id => current_user.id, :tagger_type => 'User').all %> 
0
source share

I removed this from my model:

 before_save :set_tag_owner def set_tag_owner set_owner_tag_list_on(@clown, :tags, self.tag_list) self.tag_list = nil end 

I added this to the controller in an action that processes PUT requests instead of GET requests (Update method)

 current_user.tag(@clown, :with => params[:brand][:tag_list], :on => :tags) 

Now it works.

0
source share

All Articles