Search code examples
ruby-on-railskeywordacts-as-taggable-onparam

Ruby On Rails - Acts As Taggable - Change name of param: keyword


I wonder if/how to change the name of the param :keyword when using acts as taggable?

Today my url looks like this:

http://www.foo.bar/tagged?keyword=baz

I would like to change the "keyword" to another word.

controller

  def tagged
    @current_keyword = params[:keyword]
    @tags = FeedEntry.tag_counts_on(:keyword)
    @tagged_feed_entries = FeedEntry.tagged_with(params[:keyword]).order("published_at desc").paginate :page => params[:sida]
  end

View:

 <table class="table table-striped">
    <tbody>
    <% if @tags %>

        <% @tagged_feed_entries.each do |feed_entry| %>
            <tr>
              <td>
                <% today = Date.today %>
                <% if (today === feed_entry.published_at.to_date) %>
                    <span class="label label-success">
                <% else %>
                    <span class="label">
                <% end %>
                <%= format_stamp_to_date(feed_entry.published_at) %>
                kl:
                <%= I18n.localize(feed_entry.published_at, :format => '%H:%M') %>
                </span>


              </td>
              <td><%= link_to feed_entry.name, feed_entry_path(feed_entry) %></td>
            </tr>
        <% end %>

    <% end %>
    </tbody>
  </table>

  <%= will_paginate @tagged_feed_entries, :param_name => :sida %>

Solution

  • You should just be able to replace all instances of params[:keyword] to params[:whatever]. Your path then becomes http://www.foo.bar/tagged?whatever=baz.

    If you have a search form, you'll have to make the relevant changes there, as well.