Ruby on Rails Thursday, September 1, 2011

I tried to do as you suggested but it doesn't show anything. I've tried
also to figure out if it wasn't a nil object but it's not even this.
For instance, on tag.html.erb :

<% @posts.each do |post| %>
<%= post.title.class%>
<%= post.tags%>
<%end%>

it gives as result a blank page, it not even shows which class are those
elements. But still, it doesn't either give errors.

What I did then was to change the 'tag' action in PostsController in :

@posts = Post.tagged_with(params[:id])

But then I'm wondering if the mistake isn't in the post's index.html.erb
, because this is what I did :

<% @posts.each do |post| %>
<tr>
<td><%= post.title %></td>
<td><%= post.body %></td>
<td> <% post.tag_list %>
<% b = a.to_a %>
<% b.each do |tag|%>
<%= link_to tag, {:controller => :posts, :action => :tag, :id => tag.id
}%>
<% end%>

and I did this because otherwise the tag_list would appear as a single
string merged together, even if I use a split method. This works, or at
least it makes the tags appear singularly, but still, when I go to the
url
http://0.0.0.0:3000/posts/tag/#TAG_ID#
I get and empty page, even though the ROUTES.RB has this string
uncommented:
match ':controller(/:action(/:id(.:format)))'

...no idea :-\

--
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