Hello!
I’m developing a classical Blog like app, and I’m having some kind of
issues about posts’ tags, because I’ve correctly installed
acts_as_taggable and acts_as_taggable_on_steroids gems but none of them
work, for a controller’s mismatch error (due to a Post’s tags:string
attribute I guess), but still, this is not important.
What I want to do is a Blogspot’s like schema, so basically there is the
http://website/search/label/***TAG_NAME*** url, which contains all the
posts done with this specific tag.
Well then, I’ve split the tags and each tag redirect to the correct url,
which contains all the posts made with the related tag, BUT I just
manually created the routes and templates.
The problem is : how could I tell to the controller to create an action,
or a method with the same name of those tags inside the Search
controller? I was thinking to a Proc, but I have no clue about how to
structure it. Could you help me?
And also, when I create a new Post, if I write in tags’ text_field
something like “wood,fire”, Rails will save the string as a single tag,
but what I evidently want is to .split(‘,’) this string.
Yet, I’m not able to find the place in between f.submit and the
PostsController, where the tags would be sent to the Controller already
split up.
Cos, if I put the split after the :
if @post.save
@post.tags.split(‘,’)
…in the console I get:
Post.last
=> [ #etc etc. tags : “wood,fire”]
and it isn’t split. Otherwise, if I put the .split(‘,’) method somewhere
into the _form I get errors.
So, basically I’m looking for the “place” in the middle between the
submit action and the Controller’s final check. Any idea???