Ruby on Rails Friday, September 2, 2011

1. No, in index.html.erb there's just the standard template.
in tag.html.erb I've tried to do several ways, none gives an error
but none shows the tagged posts either.
Right now I tried a simpler solution : a plain
<%@posts.each do |post| %>
<%= post.tags.class %>
<%= post.class %>
<%end%>

where @posts is
def tag
@posts = Post.tagged_with(params[:id])
end

under the PostsController.rb .

but the shown view is just empty, not even NilClass.

2. for this tag.html.erb view:
<% debug @posts.each do |post| %>
<%= debug post.title%><br>
<%= debug post.tags %>
<%end%>

I obtain :
#<Enumerable::Enumerator:0x104144240>

which is referred to <% debug @posts.each do |post| %>

if I add or delete debug on the others params, nothing changes.

3. Absolutely sure, from the console :
>> a = Post.first
=> #<Post id: 1, title: "the sea is beautiful", body: "because it's
beautiful", created_at: "2011-08-31 14:21:14", updated_at: "2011-08-31
14:21:14">
>>a.tag_list
=> ["water", "landscape"]
>>a.tags
=> [#<ActsAsTaggableOn::Tag id: 1, name: "water">,
#<ActsAsTaggableOn::Tag id: 2, name: "landscape">]

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment