how to use link_to

I have 2 controller phone phones_feature I want to give a link from phone index page to phones_feature index page and also my link is an image here is my code

<%=link_to image_tag(phone.image, :class => 'list_image'),:id=>phone.id %>

I wrote this but it doesnt work I am new I look exemples here is my phones_feature controller

def index   @phones=Phone.find(params[:id])    respond_to do |format|       format.html # index.html.erb       format.json { render json: @phones }     end   end pls dont give me alink to http://api.rubyonrails.org/ I already read there still I could not do it I look alot of example on internet

I have 2 controller phone phones_feature I want to give a link from phone index page to phones_feature index page and also my link is an image here is my code

<%=link_to image_tag(phone.image, :class => 'list_image'),:id=>phone.id %>

Get it working without the image_tag first, just as a simple link. Then add the image tag. Also if it still "doesn't work" tell us what did not work. Also have a look at the html generated and check the html is correct.

I wrote this but it doesnt work I am new I look exemples

Have you worked right through a good tutorial such as railstutorial.org, which is free to use online? If not then I suggest that would be a good idea to show you the basics of Rails.

Colin

I canged my link it is no longer image it is model part and

phone index.html.erb <% @phones.each do |phone| %>   <tr>   <td><%=image_tag(phone.image, :class => 'list_image')%></td>     <td><%= phone.brand %></td>     <td><%= link_to "#{phone.model}", :controller => :phones_feature_controller, :action => :index,:id => :phone.id %></td>     <td><%= phone.ops %></td>     <td><%= phone.price %></td>

  </tr> <% end %>

and phones_feature_controller

def index     @phones = Phone.all

    respond_to do |format|       format.html # index.html.erb       format.json { render json: @phones }     end   end

eror is :No route matches {:controller=>"phones_feature_controller"}

I canged my link it is no longer image it is model part and

Please quote the previous reply and insert you reply into it at the appropriate points so that it is easier to follow the thread. Remember that this is a mailing list not a forum (though you may be accessing it via a forum like interface).

phone index.html.erb <% @phones.each do |phone| %>   <tr>   <td><%=image_tag(phone.image, :class => 'list_image')%></td>     <td><%= phone.brand %></td>     <td><%= link_to "#{phone.model}", :controller => :phones_feature_controller, :action => :index,:id => :phone.id %></td>     <td><%= phone.ops %></td>     <td><%= phone.price %></td>

  </tr> <% end %>

and phones_feature_controller

def index     @phones = Phone.all

    respond_to do |format|       format.html # index.html.erb       format.json { render json: @phones }     end   end

eror is :No route matches {:controller=>"phones_feature_controller"}

Have you put an entry in routes.rb for the phones_feature_controller?

You did not answer my query as to whether you have worked right through a good tutorial. If you had then I would have expected you to know that this error is probably caused by something missing from routes.rb.

Colin

yes I am watching a tutorial

I add routes that   get "phones_feature/index"   get "phone/index"   get "phone/show"   get "phone/new"

I watch a video I use the same code but I had an error ( link_to ("#{phone.model}",phones_feature_index_path) it shows this line

I am sorry Ill keep in mind

I asked that you quote the previous message, and insert your reply inline, which you have not done.

yes I am watching a tutorial

Is it a Rails 3 tutorial? It should be.

I add routes that   get "phones_feature/index"   get "phone/index"   get "phone/show"   get "phone/new"

That is not the way to do it any more. I think you must be following a very old tutorial. Make sure that you are using a Rails 3 tutorial and that you are using exactly the version of rails that the tutorial is for. As I suggested previously (I think, since you have not quoted the previous message I am not sure) railstutorial.org is good.

Also make sure you restart the server when you change routes.rb.

Colin