regmiprem
regmiprem

Reputation: 735

How to send parameters through href to the controller

I have to send id in my controller like this:

<%=link_to(@active,{:controller => 'emppedes', :action=> 'index', :id => @id})%>

but using href instead of link_to. If I do this with href:

<a href="/emppedes">

the id is not sent.

<a href="/ emppedes :id => @id">

does not work. How can I send id through href?

Upvotes: 0

Views: 4637

Answers (1)

Patrick Oscity
Patrick Oscity

Reputation: 54684

Why can't you use the link_to helper? Anyway, you probably want:

<a href="/emppedes?id=<%=@id%>">

But i strongly recommend against using raw tags for links inside your app. I'm sure you can achieve everything with the link_to helper, too. Please give an example why you think you can't use it.


(In reply to your comment) I would do it this way:

<%= content_tag :li, :class => ( 'active' if @active == "personaldetails" ) do %>
  <%= link_to '/emppedes', :id => @id do %>
    <i class="icon-chevron-right"></i>
    Personal Details
  <% end %>
<% end %>

Upvotes: 1

Related Questions