Ruby on Rails
Friday, September 2, 2011
On Fri, Sep 2, 2011 at 8:08 PM, Leo M. <lists@ruby-forum.com> wrote:
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">]
so doing Post.tagged_with('water') should return the first Post record.
and going to /posts/tag/water gives a blank page? If the answer to this is yes,
give me a copy of your code, I'll try to run it locally.
--
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.
-------------------------------------------------------------
visit my blog at http://jimlabs.heroku.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.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment