# Noob problem around link\_to

**URL:** <https://www.ruby-forum.com/t/noob-problem-around-link-to/182048>\
**Category:** Rails\
**Created:** [January 21, 2010, 11:46pm UTC](https://www.ruby-forum.com/t/noob-problem-around-link-to/182048 "2010-01-21T23:46:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![radu\_puspana](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c2a13f/32.png) [@radu\_puspana](https://www.ruby-forum.com/u/radu_puspana)\
**Post date:** [January 21, 2010, 11:46pm UTC](https://www.ruby-forum.com/t/noob-problem-around-link-to/182048/1 "2010-01-21T23:46:48Z")

</div>

Good evening!

Does anyone have a spare second to help a Ruby, Rails noob? I would  
really appreciate it.

here is the chunk of code in my view relevant to my problem  
\<% if user.banned\_status == “false” %\>  
\<%= link\_to “Inspect products/orders”,:controller =\>  
“users”, :action =\> “inspect\_vendor”, :id =\> user.id, :method =\> :post  
%\>  
  
\<%#= button\_to “Inspect”, :action =\> ‘inspect\_vendor’, :id =\>  
user.id %\>  
\<% end %\>

here is the users controller  
def inspect\_vendor  
vendor\_id = params[:id]  
session[:ispected\_vendor\_id] = vendor\_id  
redirect\_to :controller =\> “products”, :action =\> “index”  
end

here is the index action in the products controller  
def index  
vendor\_id = session[:user\_id]  
@logged\_vendor = User.find\_by\_id(vendor\_id)  
if @logged\_vendor.admin\_status == “true”  
vendor\_id = session[:inspected\_user\_id]#admin inspects a vendor  
end  
@search\_results = find\_products(vendor\_id)  
#puts session.inspect  
case @search\_results  
when :no\_search  
when :empty\_query  
flash.now[:notice] = “You haven’t searched for anything.”  
when :no\_results  
flash.now[:notice] = “No results found.”  
when :results\_found  
flash.now[:notice] = “Results found!”  
end  
end  
private  
def find\_products(vendor\_id)  
if params[:search].nil? # The vendor is on the index page and  
this isn’t a search  
@products = Product.find\_products\_for\_sale(vendor\_id)  
return :no\_search  
elsif params[:search] == “” # The vendor has searched using an  
empty string  
@products = Product.find\_products\_for\_sale(vendor\_id)  
return :empty\_query  
else  
@products = Product.search(params[:search].upcase) # A  
regular search  
if @products.empty?  
@products = Product.find\_products\_for\_sale(vendor\_id)  
return :no\_results  
else  
return :results\_found  
end  
end  
end#find\_products

What I’m trying to do is:  
The admin has a list of vendors.Each vendor has an account on the  
site.The admin decides to inspect the products of a surten vendor.and  
he clicks on the link inspect\_vendor.

My problem is\> When i hover over this link is shows a different vendor  
id like it suppose, like /users/inspect\_vendor/4?method=post. But no  
matter on which link I click it takes me to the products page, but it  
shows the books that a specific vendor has(vendor with id=5)

Can you make some sense of this? Please help!

a billion thx in advance,  
radu
