hi i want to get a picture and a linke as inputs from user and then when user clicked on that picture it goes to that link related to the picture do anyone know how? thanks in advance -- Posted via http://www.ruby-forum.com/.
Ghazal Mir wrote:> hi > i want to get a picture and a linke as inputs from user and then when > user clicked on that picture it goes to that link related to the picture > do anyone know how? > thanks in advance<%= link_to image_tag( ''img1.jpg'' ), :action => ''action_to_perform'' %> -- Posted via http://www.ruby-forum.com/.
Shandy Nantz wrote:> > <%= link_to image_tag( ''img1.jpg'' ), :action => ''action_to_perform'' %>Or, if you want to use a link_to_remote: <%= link_to_remote image_tag( ''img1.jpg'' ), :url => { :action => ''action_to_perform''}, :update => ''update_div'' %> I use similar code a lot as a user interface where you don''t want another page to load. For example, if I needed to turn a value on or off I would do something like: <%= link_to_remote image_tag( @user.active ? ''chexk.jpg'' : ''ex.jpg'' ), :url => {:action => ''action_to_perform'', :id => @user.id}, :update => ''update_div'' %> -- Posted via http://www.ruby-forum.com/.
Shandy Nantz wrote:> Shandy Nantz wrote: >> >> <%= link_to image_tag( ''img1.jpg'' ), :action => ''action_to_perform'' %> > > > Or, if you want to use a link_to_remote: > > <%= link_to_remote image_tag( ''img1.jpg'' ), :url => { > :action => ''action_to_perform''}, :update => ''update_div'' %> > > I use similar code a lot as a user interface where you don''t want > another page to load. For example, if I needed to turn a value on or off > I would do something like: > > > <%= link_to_remote image_tag( @user.active ? ''chexk.jpg'' : ''ex.jpg'' ), > :url => {:action => ''action_to_perform'', :id => @user.id}, > :update => ''update_div'' %>thanks but when i use this: <%= link_to image_tag(advertise.public_filename(:thumb)) , :action => advertise.link%> it says No route matches "/advertises/www.cars.com" with {:method=>:get} how should i use it so it open a page for me and take me to address of that link? -- Posted via http://www.ruby-forum.com/.