views:

49

answers:

1

I'd like to call an action with a link_to button without being redirected to another page(I don't want ajax). For you to have an idea, I'm trying to accomplish a sort "link button" in a search page. So, when the link is clicked, the page should be refreshed showing the list ordered as I tell it in the action.

If I do the following in my view, it will ask me for a template called as the action, and I don't want it:

<%=  link_to 'M&Aacute;S RELEVANTES', search_filter_relevance_path %>

My routes file looks like this:

map.search_filter_relevance "/anuncios/buscar", :controller => 'announcements', :action => 'search_filter_relevance'

EDIT:

If I change the above line to:

map.search_filter_relevance "/anuncios/search_filter_lowest_price", :controller => 'announcements', :action => 'search_filter_relevance'

it access to the action I want it to access, but I can't figure out a way to pass the collection of items I have in the view(it's a search result) to the action, so I can filter them.

And my controller looks like this(I haven't developed the functionality yet):

  def search_filter_relevance

  end

Any help on this will be appreciated.

A: 

I believe you should define what you'll render... an action, a partial, nothing?

def search_filter_relevance
   render :action => "some_action"
   # or
   render :partial => "some_partial"
   # or
   render :nothing => true
end 

Something like that...

Maybe you could explain what you want this action to do exactly...

j.
You know what I think the problem is...I have more than one entry at routes file that links to the same page("/anuncios/buscar"), and this is the order: map.search "/anuncios/buscar", :controller => 'announcements', :action => 'search' map.power_search "/anuncios/buscar", :controller => 'announcements', :action => 'power_search' map.search_filter_relevance "/anuncios/buscar", :controller => 'announcements', :action => 'search_filter_relevance'So, it's accesing "search" action when I click the link, and not "search_filter_relevance". How can I fix this?
Brian Roisentul
I don't think so :/ I believe the problem is that you don't have a `search_filter_relevance` view and you're not telling the action to render anything else...
j.
I don't want a search_filter_relevance view. I just want the link to act as a button so when I click it, it sorts the list by a specific field. I want no rendering to any other page.
Brian Roisentul
I believe you'll have to call the `list` (or any other name you have) action with some parameters. You can make this call inside `search_filter_relevance`, then the `list` view will be rendered.
j.