view - Rails tagging fail when printing the name of the tag -


i busy building tagging system in ror. system i've coded according to: http://tutorials.jumpstartlab.com/projects/blogger.html#i3:-tagging when print out tag.name works looks entire tag_list object printed out directly next it. view render in browser clarifies problem:

#

post

tags: [ tag1 tag2 tag3 [#, #, #] ]

where each bracket shows as: tag id: 27, name: "tag1", created_at: "2015-05-12 09:24:02", updated_at: "2015-05-12 09:24:02"> ... times 3 (in case.)

#

(somehow stackoverflow doesn't show completeness of mess dealing in browser brackets.)

... direct consequence of piece of code in show.html.haml:

tags: [ = @post.tags.each |tag|     = link_to tag.name, tag_path(tag) ] 

and want this:

#

post

tags: [ tag1 tag2 tag3 ]

#

or without brackets. doesn't matter. post.rb model looks this:

    has_many :taggings     has_many :tags, through: :taggings      def tag_list=(tags_string)         tag_names = tags_string.split(",").collect{|s| s.strip.downcase}.uniq         new_or_found_tags = tag_names.collect { |name| tag.find_or_create_by(name: name) }         self.tags = new_or_found_tags     end      def tag_list         self.tags.collect |tag|           tag.name         end.join(", ")     end 

and routes.rb looks this:

rails.application.routes.draw   root 'posts#index'    resources :posts     resources :comments   end   resources :tags end 

i aware there gems tagging, me important have full control on tags development after this. tags go through complex javascript visualization libraries. it's small. help!

replace:

= @post.tags.each |tag|     = link_to tag.name, tag_path(tag) 

with:

- @post.tags.each |tag|     = link_to tag.name, tag_path(tag) 

the = prints collection


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -