0

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 %>
Philip
  • 6,827
  • 13
  • 75
  • 104

1 Answers1

0

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.

Nick Colgan
  • 5,488
  • 25
  • 36
  • The problem I'm facing when doing this is that all my previous "keywords" dissapears... How can I match the old keywords with a new param? – Philip May 29 '12 at 21:59
  • Or do I need to transfer/rename the old keywords to a new row with the name of my param in the database? – Philip May 29 '12 at 22:04
  • It shouldn't affect your records at all, unless you're changing `FeedEntry.tag_counts_on(:keyword)` as well. – Nick Colgan May 29 '12 at 22:10
  • Also, although renaming your column is not necessary, it is probably best practice and will allow you to perform mass assignment (`FeedEntry.create(params[:feed_entry])`, for example) – Nick Colgan May 29 '12 at 22:12